Skip to content

refactor(cost-map): remove openrouter rows from the cost map - #45623

Closed
devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
litellm_remove_openrouter_cost_map
Closed

devin-ai-integration[bot] wants to merge 7 commits into
mainfrom
litellm_remove_openrouter_cost_map

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenRouter returns its own price in usage.cost on every response, and since #45640 (merged) every OpenRouter path bills from it: chat, image gen and edit, Responses, /v1/decisions and the /openrouter/alpha/decisions pass-through. The 496 litellm_provider: openrouter rows in the cost map are redundant, so this PR deletes them from model_prices_and_context_window.json and litellm/model_prices_and_context_window_backup.json, regenerates model_prices_and_context_window.schema.json, and drops the tests that pinned removed keys (test_openrouter_gpt_image_model_metadata.py and single assertions in test_get_model_cost_map.py, test_utils.py, test_claude_sonnet_5_config.py, test_anthropic_chat_transformation.py, test_tool_call_cost_tracking.py). No source file changes. litellm-providers stopped syncing OpenRouter in https://github.com/BerriAI/litellm-providers/pull/254, so the rows will not come back

Reviewing the map diff

GitHub's default line diff mis-anchors on repeated lines like }, and shows thousands of insertions. Nothing is added:

git diff --diff-algorithm=histogram --shortstat origin/main... -- model_prices_and_context_window.json litellm/model_prices_and_context_window_backup.json
# 2 files changed, 20898 deletions(-)

python3 -c "import json,subprocess as s;o=json.loads(s.check_output(['git','show','origin/main:model_prices_and_context_window.json']));n=json.load(open('model_prices_and_context_window.json'));r=set(o)-set(n);print(len(r),set(n)-set(o),all(o[k]['litellm_provider']=='openrouter' for k in r),all(o[k]==n[k] for k in n))"
# 496 set() True True

496 keys removed, none added, every removed row is OpenRouter, every remaining row is byte-identical to main. The backup file prints the same

Caveats

  • litellm.get_model_info("openrouter/...") and get_max_tokens now raise ModelNotMappedError for these models
  • SDK completion_cost() on a rebuilt stream response raises for OpenRouter models
  • Bare model names no longer infer OpenRouter from litellm.openrouter_models, use the openrouter/ prefix
  • Deployments that relied on a built-in row's tiered or cache pricing lose it unless priced in config
  • If OpenRouter ever omits usage.cost, spend for that request falls back to the map and is 0

Link to Devin session: https://app.devin.ai/sessions/24b478924abd4f92b269b1556a5fcca6
Open in Devin Desktop: https://app.devin.ai/desktop/session/24b478924abd4f92b269b1556a5fcca6?variant=devin
Requested by: @kerry-berri

…om provider usage.cost

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


kerry seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Removes OpenRouter from cost pricing tables and changes cost calculation logic.

Fix custom-price priority and satisfy the provider-location and typing requirements before merging

Findings

  1. P1 Configured prices are ignored ▶
  2. P2 Provider logic enters shared code ▶
  3. P2 Stream payload type is unchecked ▶

Summary

This PR removes OpenRouter rows from both model maps and uses usage.cost for Responses, Decisions, and Decisions pass-through billing

  • OpenRouter Responses use the provider’s reported cost.
  • OpenRouter Decisions billing uses the provider’s reported cost.
  • OpenRouter chat accepts reasoning controls for every model.
  • OpenRouter models no longer have built-in price-map rows.

Acknowledgments supplied by devin-ai-integration[bot]: get_model_info and get_max_tokens failures, SDK completion_cost failures on rebuilt streams, loss of bare-name OpenRouter inference, and loss of built-in tiered/cache prices unless configured were listed as known caveats. The author also disclosed the image-cost dependency, non-reasoning parameter pass-through, a locally failing Decisions connection test, and separate provider-sync work

Reviews (1) · Last reviewed commit: "fix(openrouter): remove openrouter rows ..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing litellm_remove_openrouter_cost_map (42ac84e) with main (465f20f)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (3ebc71b) during the generation of this report, so 465f20f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

kerry-berri and others added 4 commits October 9, 2026 18:00
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration Bot changed the title fix(openrouter): remove openrouter rows from the cost map and bill from provider usage.cost refactor(cost-map): remove openrouter rows from the cost map Oct 9, 2026
kerry-berri and others added 2 commits October 9, 2026 19:11
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…uter_cost_map

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

# Conflicts:
#	tests/unit/proxy/pass_through_endpoints/llm_provider_handlers/test_typesafe_passthrough_logging_handler.py
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Superseded by the stacked deletion-only PRs #45665, #45666, #45667, #45668 and #45669, which GitHub renders without the misaligned diff

andrescrz added a commit to comet-ml/opik that referenced this pull request Oct 22, 2026
LiteLLM removed every OpenRouter row from its price file
(BerriAI/litellm#45623). The daily price update then failed the backend and
frontend tests, and merging it would have dropped OpenRouter span costs,
max output token limits and input modality flags.

- scripts/update_openrouter_model_prices.py writes
  model_prices_openrouter.json (backend and frontend copies) from
  OpenRouter's public model list, in LiteLLM's row format. The daily price
  workflow runs it; a failed fetch keeps the current file.
- CostService.readModelCosts merges both files for cost estimation and
  ModelCapabilities. The frontend model capabilities and the provider model
  sync read the OpenRouter file too.
- JsonUtils.readJsonFile throws FileNotFoundException naming a missing
  resource, and a price file that can't be read or holds no model fails
  with its name.
- Tests cover OpenRouter pricing, prompt-size tiers, vision support and the
  missing-resource error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrescrz added a commit to comet-ml/opik that referenced this pull request Oct 23, 2026
* [NA] [BE] Update model prices file

* fix(pricing): price OpenRouter models from OpenRouter's model list

LiteLLM removed every OpenRouter row from its price file
(BerriAI/litellm#45623). The daily price update then failed the backend and
frontend tests, and merging it would have dropped OpenRouter span costs,
max output token limits and input modality flags.

- scripts/update_openrouter_model_prices.py writes
  model_prices_openrouter.json (backend and frontend copies) from
  OpenRouter's public model list, in LiteLLM's row format. The daily price
  workflow runs it; a failed fetch keeps the current file.
- CostService.readModelCosts merges both files for cost estimation and
  ModelCapabilities. The frontend model capabilities and the provider model
  sync read the OpenRouter file too.
- JsonUtils.readJsonFile throws FileNotFoundException naming a missing
  resource, and a price file that can't be read or holds no model fails
  with its name.
- Tests cover OpenRouter pricing, prompt-size tiers, vision support and the
  missing-resource error.


---------

Co-authored-by: Andres Cruz <andresc@comet.com>
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