mirror of
https://github.com/usestrix/strix.git
synced 2026-09-24 00:51:20 +00:00
fix(pricing): prefer the first-party route on equally priced model ties
resolve_litellm_model() returned matches[0] (alphabetical) when several provider routes shared identical pricing, which resolves bare names like grok-4.5 to the openrouter aggregator alias instead of the first-party xai route. On a price tie, prefer the route whose model segment matches the bare name exactly, keeping alphabetical order as the fallback. Fixes #1288
This commit is contained in:
parent
2dadbb748a
commit
e71af8db03
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue