Skip to content

Commit 18d04f2

Browse files
authored
Fix error in 422 logs due to blank bearer token (#1022)
1 parent 7b98d96 commit 18d04f2

File tree

1 file changed

+10
-5
lines changed
  • openhands-sdk/openhands/sdk/llm

1 file changed

+10
-5
lines changed

openhands-sdk/openhands/sdk/llm/llm.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,11 +756,12 @@ def _init_model_info_and_caps(self) -> None:
756756
if not base_url.startswith(("http://", "https://")):
757757
base_url = "http://" + base_url
758758
try:
759+
headers = {}
759760
api_key = self.api_key.get_secret_value() if self.api_key else ""
760-
response = httpx.get(
761-
f"{base_url}/v1/model/info",
762-
headers={"Authorization": f"Bearer {api_key}"},
763-
)
761+
if api_key:
762+
headers["Authorization"] = f"Bearer {api_key}"
763+
764+
response = httpx.get(f"{base_url}/v1/model/info", headers=headers)
764765
data = response.json().get("data", [])
765766
current = next(
766767
(
@@ -777,7 +778,11 @@ def _init_model_info_and_caps(self) -> None:
777778
f"Got model info from litellm proxy: {self._model_info}"
778779
)
779780
except Exception as e:
780-
logger.debug(f"Error fetching model info from proxy: {e}")
781+
logger.debug(
782+
f"Error fetching model info from proxy: {e}",
783+
exc_info=True,
784+
stack_info=True,
785+
)
781786

782787
# Fallbacks: try base name variants
783788
if not self._model_info:

0 commit comments

Comments
 (0)