From 8ac67216413b281cf4a7a803a0c5b3b1145a5b78 Mon Sep 17 00:00:00 2001 From: michaelxer Date: Mon, 8 Jun 2026 18:18:46 +0700 Subject: [PATCH] fix: use raw model name for zero-cost lookup to support router aliases _is_model_cost_zero calls llm_router.get_model_group_info(model_group=...) which matches on the configured model_group alias. The previous code passed resolved_model (the underlying provider model from resolve_llm_provider_for_rate_limit), which does not match the router group name when aliases are in use. Use the raw request-level model string instead, matching how common_checks (user_api_key_auth.py) already calls _is_model_cost_zero. --- litellm/proxy/hooks/max_budget_limiter.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/hooks/max_budget_limiter.py b/litellm/proxy/hooks/max_budget_limiter.py index f3cb0cbbed7..bf53edd1faf 100644 --- a/litellm/proxy/hooks/max_budget_limiter.py +++ b/litellm/proxy/hooks/max_budget_limiter.py @@ -66,8 +66,9 @@ class _PROXY_MaxBudgetLimiter(CustomLogger): # CHECK IF REQUEST ALLOWED if curr_spend >= max_budget: + raw_model = data.get("model") if data else None resolved_model, llm_provider = resolve_llm_provider_for_rate_limit( - data.get("model") if data else None + raw_model ) # Zero-cost models (self-hosted / on-prem) add nothing to @@ -79,10 +80,17 @@ class _PROXY_MaxBudgetLimiter(CustomLogger): from litellm.proxy.auth.auth_checks import _is_model_cost_zero from litellm.proxy.proxy_server import llm_router - if _is_model_cost_zero(resolved_model, llm_router): + # Use raw_model (the request-level model string) for the + # cost lookup, not resolved_model. _is_model_cost_zero + # calls llm_router.get_model_group_info(model_group=...) + # which matches on the configured model_group alias. + # resolve_llm_provider_for_rate_limit returns the + # underlying provider model, which may not match the + # router group name when aliases are in use. + if _is_model_cost_zero(raw_model, llm_router): verbose_proxy_logger.debug( "MaxBudgetLimiter: Skipping budget check for zero-cost model: %s", - resolved_model, + raw_model, ) return except ImportError: