From 39cf6c13a5c2a63536151c4297195c0861b73062 Mon Sep 17 00:00:00 2001 From: marko-kraemer Date: Fri, 25 Jul 2025 20:17:02 +0200 Subject: [PATCH] Fix billing error for Grok models by adding x-ai model aliases and pricing - Added 'x-ai/grok-4' alias to xai/grok-4 model configuration - Added OpenRouter x-ai model pricing support in constants generation - Resolves LiteLLM 'LLM Provider NOT provided' errors in billing system - Ensures proper token cost calculation for all Grok model variations --- backend/utils/constants.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/utils/constants.py b/backend/utils/constants.py index 755fcb2f..fd6013be 100644 --- a/backend/utils/constants.py +++ b/backend/utils/constants.py @@ -51,7 +51,7 @@ MODELS = { "tier_availability": ["free", "paid"] }, "xai/grok-4": { - "aliases": ["grok-4"], + "aliases": ["grok-4", "x-ai/grok-4"], "pricing": { "input_cost_per_million_tokens": 5.00, "output_cost_per_million_tokens": 15.00 @@ -152,6 +152,10 @@ def _generate_model_structures(): # Add anthropic/claude-sonnet-4 alias for claude-sonnet-4-20250514 if "claude-sonnet-4-20250514" in model_name: pricing["anthropic/claude-sonnet-4"] = config["pricing"] + elif model_name.startswith("xai/"): + # Add pricing for OpenRouter x-ai models + openrouter_name = model_name.replace("xai/", "openrouter/x-ai/") + pricing[openrouter_name] = config["pricing"] return free_models, paid_models, aliases, pricing