This commit is contained in:
Helena Van 2026-09-18 20:15:19 +03:00 committed by GitHub
commit 1560c2e365
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,7 +48,10 @@ def resolve_litellm_model(model: str) -> str | None:
if isinstance(model_cost.get(key), dict)
}
if len(matches) == 1 or len(prices) == 1:
return matches[0]
# On a price tie, prefer the route whose model segment is exactly the
# bare name (the first-party route) over aggregator aliases like
# openrouter/x-ai/<model>; fall back to alphabetical order.
return min(matches, key=lambda key: (key.split("/", 1)[1] != name, key))
return None # noqa: TRY300
except Exception: # noqa: BLE001
return None