This commit is contained in:
Rithvik Mysore Suresh 2026-08-27 19:07:53 -05:00 • committed by GitHub
commit 340d4904d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View file

@ -456,8 +456,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:

View file

@ -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: