mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix(router): use custom model_id pricing when litellm_model_name_model_info is missing
Return custom_model_info from get_deployment_model_info when litellm_model_name_model_info is unavailable. This preserves explicit input_cost_per_token and output_cost_per_token values (including 0.0) for custom deployments and prevents model_group_info from defaulting to None costs.
This commit is contained in:
parent
e64d98f725
commit
c324364ba5
2 changed files with 21 additions and 0 deletions
|
|
@ -7754,6 +7754,8 @@ class Router:
|
|||
)
|
||||
elif litellm_model_name_model_info is not None:
|
||||
model_info = litellm_model_name_model_info
|
||||
elif custom_model_info is not None:
|
||||
model_info = cast(ModelInfo, custom_model_info)
|
||||
|
||||
return model_info
|
||||
|
||||
|
|
|
|||
|
|
@ -1955,6 +1955,25 @@ def test_get_deployment_model_info_base_model_flow():
|
|||
# Should return None when no model info is found
|
||||
assert result is None
|
||||
|
||||
# Test Case 6: Only custom model info exists (no model-name info)
|
||||
mock_custom_only_info = {
|
||||
"input_cost_per_token": 0.0,
|
||||
"output_cost_per_token": 0.0,
|
||||
"mode": "chat",
|
||||
"litellm_provider": "openai",
|
||||
}
|
||||
|
||||
with patch.object(litellm, "model_cost", {"custom-only-id": mock_custom_only_info}):
|
||||
with patch.object(litellm, "get_model_info", return_value=None):
|
||||
result = router.get_deployment_model_info(
|
||||
model_id="custom-only-id", model_name="missing-model-name"
|
||||
)
|
||||
|
||||
assert result is not None
|
||||
assert result["input_cost_per_token"] == 0.0
|
||||
assert result["output_cost_per_token"] == 0.0
|
||||
assert result["litellm_provider"] == "openai"
|
||||
|
||||
print("✓ All base model flow test cases passed!")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue