chore: remove unused keys from model cost map - #31528
Conversation
b3184ec to
08272d7
Compare
|
Generated by Claude Code |
Greptile SummaryThis PR cleans up unused model-cost map fields and keeps the validation test aligned. The main changes are:
Confidence Score: 5/5The 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.
What T-Rex did
Reviews (4): Last reviewed commit: "chore: remove unused keys from model cos..." | Re-trigger Greptile |
|
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. On the public-data-contract point, you're correct that a consumer reading Generated by Claude Code |
|
bugbot run Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ 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.
08272d7 to
0655b25
Compare
|
Good catch on The distinction is that 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. Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ 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.
0655b25 to
2c4baf4
Compare
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ 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.
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / 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.
Output:
Type
🧹 Refactoring
Changes
This removes 25 keys from
model_prices_and_context_window.json(and its packaged twinlitellm/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_infodoes not surface it, it is not built dynamically through the service-tier suffix or above-threshold key construction inlitellm/litellm_core_utils/llm_cost_calc/utils.py, and no test asserts a value for it. The correspondingINTENDED_SCHEMAand cost-field entries intests/test_litellm/test_utils.pyare pruned in lockstep so the JSON-validity test stays accurateThe 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, andtool_use_system_prompt_tokensdeprecation_datewas deliberately kept even though no merged code reads it yet. PR #26900 (proactive model deprecation alerts and the/model/deprecationsendpoint) is in flight and consumesdeprecation_datestraight offlitellm.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 staysA 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_tokensandinput_cost_per_audio_token_priorityare 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), andsupported_modalities/supported_output_modalities(azure kimi, gemini realtime)supports_image_inputwas also kept, even though no litellm code reads it. It is a documented deprecated public alias forsupports_embedding_image_input: theamazon.titan-embed-image-v1andembed-english-v3.0entries carry ametadata.notesstring 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 makelitellm.model_cost[...]["supports_image_input"]raiseKeyErrorfor direct consumers mid-deprecation and would orphan that note, so it stays until there is an explicit removal milestoneHeads-up on impact: several of the removed keys are widely populated curated metadata rather than stray entries;
supports_service_tieris 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 offlitellm.model_costwould lose that metadata, so flagging it explicitly for reviewNote 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 requireNote
Low Risk
Refactor of unused JSON metadata with no Python consumers; main risk is external callers that read removed keys from
litellm.model_costdirectly.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 includesupports_service_tieron many Azure/OpenAI/Gemini entries, Gemini media caps likemax_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_coston image models, and Perplexitysupports_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_inputon 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.