Skip to content

fix(proxy_server): populate model_info when cost keys are present but None (#40741) - #40756

Open
tusharjamunkar wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
tusharjamunkar:fix/proxy-enrich-model-info-none
Open

fix(proxy_server): populate model_info when cost keys are present but None (#40741)#40756
tusharjamunkar wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
tusharjamunkar:fix/proxy-enrich-model-info-none

Conversation

@tusharjamunkar

@tusharjamunkar tusharjamunkar commented Sep 11, 2026

Copy link
Copy Markdown

TLDR

Problem this solves:

  • ModelInfo serialization dumps fields with None values
  • proxy_server.py checked if k not in model_info:
  • Existing None values blocked model cost map enrichment
  • Missing pricing broke concurrent budget reservation

How it solves it:

  • Check if model_info.get(k) is None: at both merge sites
  • Missing and None fields get enriched with litellm cost data
  • Preserves custom user-specified pricing values

User Flow

Before: a proxy user configures a model deployment without explicit per-token pricing, and concurrent budget reservations fail to estimate spend, allowing requests through with $0 estimated spend

  1. Proxy initializes a model deployment with default ModelInfo fields (where input_cost_per_token=None, etc.)
  2. proxy_server._enrich_model_info_with_litellm_data sees k in model_info (with value None) and skips filling in litellm's default pricing
  3. The model's cost map remains empty/None, leading concurrent request budget reservations to evaluate spend at $0.0

After: the proxy initializes the model deployment, enriches unset/None fields with standard model pricing, and preserves any custom pricing overrides

  1. Proxy initializes the same model deployment with default ModelInfo
  2. proxy_server._enrich_model_info_with_litellm_data checks if model_info.get(k) is None: and populates input_cost_per_token, output_cost_per_token, and other metadata from the default cost map
  3. The model has accurate pricing info, enabling concurrent budget reservations to accurately track spend

Relevant issues

Fixes #40741

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Before (dfab479)

  1. Run reproduction script querying _enrich_model_info_with_litellm_data with default ProxyModelInfo
  2. Observed output: input_cost_per_token: None, max_tokens: None, mode: None (pricing was skipped because keys were present with None value)

After (80f4d7e)

  1. Run reproduction script querying _enrich_model_info_with_litellm_data with default ProxyModelInfo
  2. Observed output: input_cost_per_token: 5.5e-06, max_tokens: 128000, mode: 'chat' (pricing and token limits populated from cost map)
  3. Run with custom override: input_cost_per_token: 0.00099 is preserved

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@tusharjamunkar
tusharjamunkar requested a review from a team September 11, 2026 17:41
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates both model-info enrichment paths to populate metadata whose existing value is None, while preserving explicit user values.

  • Populates pricing, token limits, and other metadata from LiteLLM’s model-cost data when unset.
  • Adds direct regression coverage for both enrichment functions.
  • Verifies that custom pricing overrides remain unchanged.

Confidence Score: 5/5

The PR appears safe to merge, with focused regression coverage for both affected enrichment paths.

No actionable new issues remain. The previously reported test gap is resolved by independently invoking _get_proxy_model_info with a fresh model whose metadata fields are None.

Important Files Changed

Filename Overview
litellm/proxy/proxy_server.py Both model-info merge sites now treat missing and None values as unset while preserving non-None overrides.
tests/test_litellm/proxy/proxy_server/test_routes_model_info.py Adds independent regression tests for both merge paths and coverage for preserving custom pricing.

Reviews (2): Last reviewed commit: "test(proxy_server): add independent regr..." | Re-trigger Greptile

Comment thread tests/test_litellm/proxy/proxy_server/test_routes_model_info.py Outdated
@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing tusharjamunkar:fix/proxy-enrich-model-info-none (80f4d7e) with litellm_internal_staging (dfab479)

Open in CodSpeed

@tusharjamunkar

Copy link
Copy Markdown
Author

@greptileai

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant