From 136e09534ac8d8bed1ddd886e666c7c57a53c3e4 Mon Sep 17 00:00:00 2001 From: Rithvik Mysore Suresh Date: Fri, 31 Jul 2026 10:25:23 -0400 Subject: [PATCH] fix(auth): resolve zero-cost model aliases Alias pricing resolves through its target model group, but explicit-cost validation searched under the alias name and enforced budgets on free models.\n\nFixes #35369 --- litellm/proxy/auth/auth_checks.py | 3 ++- .../test_zero_cost_model_budget_bypass.py | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/auth/auth_checks.py b/litellm/proxy/auth/auth_checks.py index 263fec77d12..1b0fc30b9f3 100644 --- a/litellm/proxy/auth/auth_checks.py +++ b/litellm/proxy/auth/auth_checks.py @@ -263,8 +263,9 @@ def _is_cost_explicitly_configured(model: str, llm_router: "Router") -> bool: fields. _get_model_info_helper() then defaults missing costs to 0. This function detects that scenario by checking the raw model_cost entry. """ + resolved_model = llm_router._get_model_from_alias(model) or model for deployment in llm_router.model_list: - if deployment.get("model_name") != model: + if deployment.get("model_name") != resolved_model: continue model_id = deployment.get("model_info", {}).get("id") if model_id is None: diff --git a/tests/proxy_unit_tests/test_zero_cost_model_budget_bypass.py b/tests/proxy_unit_tests/test_zero_cost_model_budget_bypass.py index 51a7cb2ee9d..ed2fa6c8993 100644 --- a/tests/proxy_unit_tests/test_zero_cost_model_budget_bypass.py +++ b/tests/proxy_unit_tests/test_zero_cost_model_budget_bypass.py @@ -108,6 +108,26 @@ class TestIsModelCostZero: ) assert result is True + @pytest.mark.parametrize( + "alias_target", + [ + "on-prem-model", + {"model": "on-prem-model", "hidden": False}, + ], + ) + def test_zero_cost_model_group_alias( + self, mock_router_with_zero_cost_model, alias_target + ): + mock_router_with_zero_cost_model.model_group_alias = { + "free-alias": alias_target + } + + result = _is_model_cost_zero( + model="free-alias", llm_router=mock_router_with_zero_cost_model + ) + + assert result is True + def test_paid_model_in_router(self, mock_router_with_zero_cost_model): """Test that a paid model is correctly identified as non-zero cost.""" with patch("litellm.get_model_info") as mock_get_model_info: