π OpenHands: AI-Driven Development
Fix Openrouter (#4641)
Engel Nystbde978cf0ff3
diff --git a/openhands/llm/llm.py b/openhands/llm/llm.pyindex ba887a3542..5fbd8da9c8 100644--- a/openhands/llm/llm.py+++ b/openhands/llm/llm.py@@ -91,9 +91,13 @@ class LLM(RetryMixin, DebugMixin):# litellm actually uses base Exception here for unknown modelself.model_info: ModelInfo | None = None- if self.config.model.startswith('openrouter'):- self.model_info = litellm.get_model_info(self.config.model)- elif self.config.model.startswith('litellm_proxy/'):+ try:+ if self.config.model.startswith('openrouter'):+ self.model_info = litellm.get_model_info(self.config.model)+ except Exception as e:+ logger.debug(f'Error getting model info: {e}')++ if self.config.model.startswith('litellm_proxy/'):# IF we are using LiteLLM proxy, get model info from LiteLLM proxy# GET {base_url}/v1/model/info with litellm_model_id as path paramresponse = requests.get(