#40741·litellm

[Bug]: model_info keys present but None block cost-map enrichment, silently disabling budget reservation

Author: mwill-pubCreated Sep 11, 2026Updated Sep 29, 2026
Labelsllm translation

What happens

litellm.proxy._types.ModelInfo declares input_cost_per_token = 0.0 and max_tokens = 2048, but its set_model_info validator overwrites those defaults with None when the caller does not supply them:

python
@model_validator(mode="before")
@classmethod
def set_model_info(cls, values):
    ...
    if values.get("input_cost_per_token") is None:
        values.update({"input_cost_per_token": None})

So model_dump() emits input_cost_per_token: None and output_cost_per_token: None for any model without custom pricing. An absent key becomes a key that is present and None.

Both cost-map enrichment sites merge with if k not in model_info (proxy_server.py:11761 in _enrich_model_info_with_litellm_data, and proxy_server.py:13177 in _get_proxy_model_info). That only fills keys which are absent. A key present with value None is never filled.

So a model that is priced in the built-in cost map reads back as unpriced. estimate_request_max_cost then returns 0.0, and reserve_budget_for_request reserves nothing, so the atomic pre-call budget reservation stops bounding concurrent spend. There is no error and no log line.

This is the None half of the write-back problem described in #30198. PR #30201 fixed the synthesized-zero half; the issue text also noted "the write-back persists the entire synthesized ModelInfoBase blob, so a sparse entry also gains dozens of explicit None fields", and that half is still present. #25839 is the same shape seen from /model/update.

Reproduction

v1.97.0. The only variable is how model_info was constructed.

python
import os
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"

import litellm
from litellm.proxy._types import ModelInfo as ProxyModelInfo
from litellm.proxy.proxy_server import _enrich_model_info_with_litellm_data
from litellm.proxy.spend_tracking.budget_reservation import estimate_request_max_cost
from litellm.router import Router

BACKEND = "bedrock/eu.anthropic.claude-opus-5"   # priced at 5.5e-06 in the built-in map
BODY = {"model": "m", "messages": [{"role": "user", "content": "x " * 500}], "max_tokens": 8}

for label, model_info in (
    ("absent cost keys", {"id": "d1"}),
    ("proxy ModelInfo", ProxyModelInfo(id="d1").model_dump()),
):
    model = {"model_name": "m", "litellm_params": {"model": BACKEND}, "model_info": dict(model_info)}
    mi = _enrich_model_info_with_litellm_data(model=model, llm_router=None)["model_info"]
    router = Router(model_list=[{"model_name": "m", "litellm_params": {"model": BACKEND},
                                "model_info": dict(model_info)}])
    est = estimate_request_max_cost(request_body=dict(BODY), route="/chat/completions", llm_router=router)
    print(label, "->", mi.get("input_cost_per_token"), "| estimate:", est)

Output:

proxy ModelInfo(id=...).model_dump()
  {'id': 'd1', 'mode': None, 'input_cost_per_token': None,
   'output_cost_per_token': None, 'max_tokens': None, 'base_model': None}

absent cost keys -> 5.5e-06 | estimate: 0.005763999999999999
proxy ModelInfo  -> None    | estimate: 0.0

max_input_tokens still enriches correctly to 1000000 in both cases, because it is not one of the declared fields. Only the declared-but-unset keys are affected, which makes this hard to spot: everything else about the model looks right.

Impact

On a proxy where model_info reaches enrichment via the management or database path, /model/info and /model_group/info report input_cost_per_token: null for models that are priced in the cost map, and per-key and per-team budgets stop being enforced under concurrency. Post-call cost tracking is unaffected, because it resolves pricing separately, so spend reporting stays correct and hides the enforcement gap.

We hit this on a proxy serving three Bedrock models. A twenty-wide concurrent burst at a key with $0.02 of budget admitted all twenty requests and spent $0.225, about eleven times the cap. With pricing resolving, the same burst admits four.

Suggested fix

Treat a present-but-None key as absent at both merge sites, which matches the intent of only filling what the operator has not set:

python
for k, v in litellm_model_info.items():
    if model_info.get(k) is None:
        model_info[k] = v

This mirrors the existing litellm_provider-is-None guard in register_model and the cost-field guard added by #30201.

Workaround

Set the costs explicitly on each model_list entry, which gives the keys real values instead of None.

Version

Reproduced on v1.97.0 (PyPI package and ghcr.io/berriai/litellm-database:v1.97.0). Both merge sites and the set_model_info validator are unchanged on main at 67cb34c, and the same reproduction gives the same result there.