This commit is contained in:
Srivatsa Kamballa 2026-08-26 22:10:52 -05:00 committed by GitHub
commit a4ada4cb1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -12632,7 +12632,7 @@ def _enrich_model_info_with_litellm_data(
except Exception:
litellm_model_info = {}
for k, v in litellm_model_info.items():
if k not in model_info:
if model_info.get(k) is None:
model_info[k] = v
model["model_info"] = model_info
# don't return the api key / vertex credentials

View file

@ -69,6 +69,31 @@ def test_v2_model_info_in_openapi_schema():
assert "get" in schema["paths"]["/v2/model/info"]
def test_v2_model_info_enrichment_heals_none_valued_cost_keys():
"""A deployment that has served a request carries its cost keys as explicit None, because
Deployment materialises every unset ModelInfo field. Backfilling only absent keys left those
None values unhealed, so this route reported no pricing for exactly the models in use."""
from litellm.proxy.proxy_server import _enrich_model_info_with_litellm_data
base = {
"model_name": "claude-haiku-4-5",
"litellm_params": {"model": "anthropic/claude-haiku-4-5-20251001"},
}
absent = _enrich_model_info_with_litellm_data(model={**base, "model_info": {"id": "abc"}})
expected = absent["model_info"]["input_cost_per_token"]
assert expected is not None
served = _enrich_model_info_with_litellm_data(
model={
**base,
"model_info": {"id": "abc", "input_cost_per_token": None, "output_cost_per_token": None},
}
)
assert served["model_info"]["input_cost_per_token"] == expected
assert served["model_info"]["output_cost_per_token"] is not None
# ---------------------------------------------------------------------------
# GET /v1/model/info, GET /model/info
# ---------------------------------------------------------------------------