From 76267dc97e3e10cd31f31d6b568c4ff63c716054 Mon Sep 17 00:00:00 2001 From: itzzdev09 Date: Mon, 14 Sep 2026 12:17:13 +0530 Subject: [PATCH] fix(pricing): prefer the direct provider when resellers list the same price LiteLLM's cost map now lists grok-4.5 under xai/, perplexity/xai/ and openrouter/x-ai/ at identical prices, so alphabetical order resolved the bare name to openrouter and failed test_resolves_common_bare_model_names. Co-Authored-By: Claude Opus 5 --- strix/report/pricing.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/strix/report/pricing.py b/strix/report/pricing.py index 57c89959..41f9c1bf 100644 --- a/strix/report/pricing.py +++ b/strix/report/pricing.py @@ -36,7 +36,12 @@ def resolve_litellm_model(model: str) -> str | None: if "/" in normalized: names.append(normalized.rsplit("/", 1)[-1]) for name in names: - matches = sorted(key for key in model_cost if key.endswith(f"/{name}")) + # Prefer the direct provider (``xai/grok-4.5``) over resellers + # listing the same model (``openrouter/x-ai/grok-4.5``). + matches = sorted( + (key for key in model_cost if key.endswith(f"/{name}")), + key=lambda key: (key.count("/"), key), + ) if not matches: continue prices = {