Skip to content

chore: remove unused keys from model cost map - #31528

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_remove_unused_model_config_keys
Jun 27, 2026
Merged

chore: remove unused keys from model cost map#31528
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_remove_unused_model_config_keys

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Pre-Submission checklist

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

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

This is a dead-data cleanup with no runtime behavior change, so the proof is that the cost map still loads and every model's typed info is still resolvable after the keys are gone, while the removed keys are absent from the map and the kept ones stay. Run against the local map so it reads the files in this PR rather than the remote copy.

LITELLM_LOCAL_MODEL_COST_MAP=True python -c "
import litellm
mc = litellm.model_cost
print('models loaded:', len(mc))
litellm.get_model_info('gemini/gemini-2.0-flash')   # resolves without error
removed = ['supports_service_tier','max_pdf_size_mb','tool_use_system_prompt_tokens','supported_resolutions','max_images_per_prompt']
print('removed keys still present:', sorted({k for m in mc.values() if isinstance(m, dict) for k in removed if k in m}))
print('deprecation_date retained on gemini-2.0-flash:', mc['gemini-2.0-flash'].get('deprecation_date'))
print('models still carrying deprecation_date:', sum('deprecation_date' in m for m in mc.values() if isinstance(m, dict)))
print('supports_image_input retained on titan-embed-image-v1:', 'supports_image_input' in mc['amazon.titan-embed-image-v1'])
"

Output:

models loaded: 2909
removed keys still present: []
deprecation_date retained on gemini-2.0-flash: 2026-06-01
models still carrying deprecation_date: 93
supports_image_input retained on titan-embed-image-v1: True

Type

🧹 Refactoring

Changes

This removes 25 keys from model_prices_and_context_window.json (and its packaged twin litellm/model_prices_and_context_window_backup.json) that nothing in the codebase actually reads. For each removed key there is no code that consumes it; get_model_info does not surface it, it is not built dynamically through the service-tier suffix or above-threshold key construction in litellm/litellm_core_utils/llm_cost_calc/utils.py, and no test asserts a value for it. The corresponding INTENDED_SCHEMA and cost-field entries in tests/test_litellm/test_utils.py are pruned in lockstep so the JSON-validity test stays accurate

The removed keys are cache_read_input_image_token_cost, cache_read_input_token_cost_batches, cache_read_input_token_cost_per_audio_token, input_cost_per_token_batch_requests, max_audio_length_hours, max_audio_per_prompt, max_document_chunks_per_query, max_images_per_prompt, max_pdf_size_mb, max_query_tokens, max_tokens_per_document_chunk, max_video_length, max_videos_per_prompt, output_cost_per_image_above_1024_and_1024_pixels, output_cost_per_image_above_1024_and_1024_pixels_and_premium_image, output_cost_per_image_above_512_and_512_pixels, output_cost_per_image_above_512_and_512_pixels_and_premium_image, output_cost_per_image_premium_image, output_cost_per_image_token_batches, supported_resolutions, supports_code_execution, supports_file_search, supports_preset, supports_service_tier, and tool_use_system_prompt_tokens

deprecation_date was deliberately kept even though no merged code reads it yet. PR #26900 (proactive model deprecation alerts and the /model/deprecations endpoint) is in flight and consumes deprecation_date straight off litellm.model_cost; stripping it now would leave that feature with no data to surface for the ~93 models that carry a real date today (for example gemini/gemini-2.0-flash), so it stays

A few other keys that a naive literal grep flags as unused were also kept because they are live. The dynamically-constructed cost keys such as input_cost_per_token_above_256k_tokens, output_cost_per_token_above_256k_tokens, cache_creation_input_token_cost_above_1hr_above_200k_tokens and input_cost_per_audio_token_priority are resolved at runtime via f-strings and the service-tier suffix logic, so removing them would silently break cost calculation. Others are passthrough metadata read from the raw cost map and pinned by real tests: input_dbu_cost_per_token / output_dbu_cost_per_token (databricks pricing), supports_video_input (moonshot), supports_multimodal (gemini-embedding-2), and supported_modalities / supported_output_modalities (azure kimi, gemini realtime)

supports_image_input was also kept, even though no litellm code reads it. It is a documented deprecated public alias for supports_embedding_image_input: the amazon.titan-embed-image-v1 and embed-english-v3.0 entries carry a metadata.notes string spelling out "'supports_image_input' is a deprecated field. Use 'supports_embedding_image_input' instead", and it is set on six embedding models. Dropping it would make litellm.model_cost[...]["supports_image_input"] raise KeyError for direct consumers mid-deprecation and would orphan that note, so it stays until there is an explicit removal milestone

Heads-up on impact: several of the removed keys are widely populated curated metadata rather than stray entries; supports_service_tier is set on roughly 80 to 90 models, and a cluster of media-limit fields (max_images_per_prompt, max_audio_length_hours, max_pdf_size_mb, max_video_length, max_videos_per_prompt) on about 64 each. No litellm code branches on them, but anyone reading them straight off litellm.model_cost would lose that metadata, so flagging it explicitly for review

Note on the diff size: the two JSON files also carry a small amount of pre-existing drift between each other (extra snowflake/* entries and some non-standard indentation in the root file) that predates this branch; that was left untouched, so the per-file diffs here are only the key removals plus the trailing-comma fixes they require


Note

Low Risk
Refactor of unused JSON metadata with no Python consumers; main risk is external callers that read removed keys from litellm.model_cost directly.

Overview
Trims dead metadata from model_prices_and_context_window_backup.json (and the paired primary cost map per the PR) by deleting 25 keys that no LiteLLM code reads—examples include supports_service_tier on many Azure/OpenAI/Gemini entries, Gemini media caps like max_pdf_size_mb / max_images_per_prompt, rerank limits (max_query_tokens, max_document_chunks_per_query), Titan/Runway/Sora premium-resolution image cost fields, cache_read_input_image_token_cost on image models, and Perplexity supports_preset.

Intentionally not removed in this cleanup: deprecation_date (for in-flight deprecation surfacing), dynamically resolved *_above_* / priority cost keys, and a few passthrough fields still covered by tests or docs (supports_image_input on Titan embed, etc.).

This is data-only; runtime behavior should be unchanged unless something depended on reading those keys directly off litellm.model_cost.

Reviewed by Cursor Bugbot for commit 2c4baf4. Bugbot is set up for automated code reviews on this repo. Configure here.

@mateo-berri
mateo-berri force-pushed the litellm_remove_unused_model_config_keys branch from b3184ec to 08272d7 Compare June 27, 2026 22:38
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai


Generated by Claude Code

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR cleans up unused model-cost map fields and keeps the validation test aligned. The main changes are:

  • Removed unused pricing and metadata keys from model_prices_and_context_window.json.
  • Applied the same key removals to litellm/model_prices_and_context_window_backup.json.
  • Pruned the corresponding schema and cost-field allowlists in tests/test_litellm/test_utils.py.

Confidence Score: 5/5

The changes are limited to removing unused cost-map fields and keeping the associated validation allowlists aligned.

The touched files are data/schema cleanup only, with no accepted issues identified in the reviewed changes.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex compared pre-artifact and post-artifact model info and confirmed removed_keys_present is empty in the head state, with GET_MODEL_INFO_STATUS OK and exit code 0.
  • T-Rex inspected the base artifact showing model_count 2909, deprecation_date_count 93, and retained-key counts, and confirmed the head artifact reports the same counts.
  • T-Rex ran executable validation and noted before: 2917 model entries with 159 schema properties and after: 2917 model entries with 134 properties, both with errors=0 and SCHEMA_VALIDATION_PASSED, and documented that the initial pytest attempt was blocked due to missing pytest with a fallback command captured.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (4): Last reviewed commit: "chore: remove unused keys from model cos..." | Re-trigger Greptile

@mateo-berri

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, and for actually running the repro. The 4/5 here reflects a design decision rather than an unaddressed defect, so let me clarify why.

Every removed key is dead data from litellm's perspective: nothing in the library reads it. get_model_info does not surface any of them, none are reconstructed through the service-tier suffix or the above-threshold f-string logic in litellm/litellm_core_utils/llm_cost_calc/utils.py, and no test asserts a value for them. The keys a literal grep makes look unused but that are actually live (the dynamically built above-threshold and service-tier cost keys, plus passthrough metadata like supports_multimodal, supported_modalities, input_dbu_cost_per_token, supports_video_input) were deliberately kept, which is why those counts are unchanged in your T-Rex run.

On the public-data-contract point, you're correct that a consumer reading litellm.model_cost directly would no longer see fields like deprecation_date or supports_service_tier. That impact is intentional and is already called out explicitly in the PR description for maintainer visibility; gating or re-preserving the fields would defeat the cleanup, so I'd rather surface the tradeoff than hide it. If the team decides a specific field is worth keeping as curated public metadata even though litellm itself never consumes it, I'm happy to re-add just that one


Generated by Claude Code

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run


Generated by Claude Code

@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 08272d7. Configure here.

@mateo-berri
mateo-berri marked this pull request as ready for review June 27, 2026 22:47
@mateo-berri
mateo-berri force-pushed the litellm_remove_unused_model_config_keys branch from 08272d7 to 0655b25 Compare June 27, 2026 22:54
@mateo-berri

Copy link
Copy Markdown
Contributor Author

Good catch on supports_image_input; that one is genuinely different from the rest, so I've kept it in 0655b25 and dropped it from the removal set.

The distinction is that supports_image_input is a documented deprecated public alias, not stray dead data. The amazon.titan-embed-image-v1 and embed-english-v3.0 entries carry a metadata.notes string that literally says "'supports_image_input' is a deprecated field. Use 'supports_embedding_image_input' instead", and the field is set on six embedding models. Removing it would make litellm.model_cost[...]["supports_image_input"] raise KeyError for direct consumers in the middle of its documented deprecation, and it would orphan that note so it points at a field that no longer exists. There's no removal milestone recorded for it, so ending the deprecation now isn't my call to make in a cleanup PR; it stays.

The other 26 keys don't have that property. None are read by litellm, none are reconstructed by the dynamic cost-key logic, none are pinned by a test, and none are self-documented as a compatibility alias, so those remain removed. The PR description is updated to match.

@greptileai


Generated by Claude Code

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0655b25. Configure here.

@mateo-berri
mateo-berri force-pushed the litellm_remove_unused_model_config_keys branch from 0655b25 to 2c4baf4 Compare June 27, 2026 23:04
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai


Generated by Claude Code

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run


Generated by Claude Code

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2c4baf4. Configure here.

@mateo-berri
mateo-berri merged commit ef3dcf9 into litellm_internal_staging Jun 27, 2026
126 checks passed
@mateo-berri
mateo-berri deleted the litellm_remove_unused_model_config_keys branch June 27, 2026 23:29
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 30, 2026
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.

2 participants