Skip to content

fix(models): sync openrouter prices from the models API - #42832

Merged
kerry-berri merged 2 commits into
mainfrom
litellm_sync_openrouter
Sep 24, 2026
Merged

kerry-berri merged 2 commits into
mainfrom
litellm_sync_openrouter

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • 18 openrouter cost map rows drifted from the OpenRouter models API
  • Qwen tiered (above 32k / 128k / 256k) prices were missing on 7 rows

How it solves it:

  • Rewrites those fields from GET https://openrouter.ai/api/v1/models, per token
  • Regenerates model_prices_and_context_window.schema.json for the new tiered field names

User Flow

Before: a proxy admin routing to openrouter/deepseek/deepseek-v4-flash sees spend logged at half the current OpenRouter rate

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "openrouter/deepseek/deepseek-v4-flash"
  2. The response usage is priced at 4.9e-08 per input token, 9.8e-08 per output token
  3. https://litellm-domain/ui/?page=logs shows spend below what OpenRouter bills

After: the same request is priced at the rate OpenRouter currently lists

  1. They send the same POST https://litellm-domain/v1/chat/completions
  2. The response usage is priced at 8.8606e-08 per input token, 1.77212e-07 per output token
  3. https://litellm-domain/ui/?page=logs matches the OpenRouter invoice

Rows changed

Every row below comes from npm run providers -- prices openrouter in BerriAI/litellm-providers, which reads GET https://openrouter.ai/api/v1/models (fetched 2026-09-24T00:35:07Z). Values are USD per token as the API returns them. No rows were added and no context window values changed

  • openrouter/deepseek/deepseek-v4-flash (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 9.8e-08 -> 1.77212e-07
    • cache_read_input_token_cost: 9.8e-09 -> 1.77212e-08
    • input_cost_per_token: 4.9e-08 -> 8.8606e-08
  • openrouter/deepseek/deepseek-v4-pro (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 1.76088e-06 -> 1.8792e-06
    • cache_read_input_token_cost: 7.337e-08 -> 7.83e-08
    • input_cost_per_token: 8.8044e-07 -> 9.396e-07
  • openrouter/deepseek/deepseek-v4-pro-0813 (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 3.96e-06 -> 1.386e-06
    • cache_read_input_token_cost: 4.4e-08 -> 1.54e-08
    • input_cost_per_token: 1.32e-06 -> 4.62e-07
  • openrouter/deepseek/deepseek-v4.1-flash (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 1.2e-06 -> 4.2e-07
    • cache_read_input_token_cost: 6e-09 -> 4.2e-09
    • input_cost_per_token: 3e-07 -> 1.4e-07
  • openrouter/minimax/minimax-m2 (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 1.02e-06 -> 1.2e-06
    • input_cost_per_token: 2.55e-07 -> 3e-07
  • openrouter/nvidia/nemotron-3.5-lightning (kind: api, source https://openrouter.ai/api/v1/models)
    • input_cost_per_token: 7e-08 -> 8e-08
  • openrouter/qwen/qwen3-coder-flash (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_32k_tokens: unset -> 1.625e-06
    • cache_read_input_token_cost_above_32k_tokens: unset -> 6.5e-08
    • cache_creation_input_token_cost_above_32k_tokens: unset -> 4.0625e-07
    • input_cost_per_token_above_32k_tokens: unset -> 3.25e-07
  • openrouter/qwen/qwen3-coder-plus (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_32k_tokens: unset -> 5.85e-06
    • cache_read_input_token_cost_above_32k_tokens: unset -> 2.34e-07
    • cache_creation_input_token_cost_above_32k_tokens: unset -> 1.4625e-06
    • input_cost_per_token_above_32k_tokens: unset -> 1.17e-06
    • cache_read_input_token_cost_above_128k_tokens: unset -> 3.9e-07
    • cache_creation_input_token_cost_above_128k_tokens: unset -> 2.4375e-06
  • openrouter/qwen/qwen3-max (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_32k_tokens: unset -> 7.8e-06
    • cache_read_input_token_cost_above_32k_tokens: unset -> 3.12e-07
    • cache_creation_input_token_cost_above_32k_tokens: unset -> 1.95e-06
    • input_cost_per_token_above_32k_tokens: unset -> 1.56e-06
  • openrouter/qwen/qwen3-max-thinking (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_32k_tokens: unset -> 7.8e-06
    • input_cost_per_token_above_32k_tokens: unset -> 1.56e-06
  • openrouter/qwen/qwen3-next-80b-a3b-instruct (kind: api, source https://openrouter.ai/api/v1/models)
    • input_cost_per_token: 9e-08 -> 1e-07
  • openrouter/qwen/qwen3.5-plus-02-15 (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_256k_tokens: 3e-06 -> 1.95e-06
    • input_cost_per_token_above_256k_tokens: 5e-07 -> 3.25e-07
  • openrouter/qwen/qwen3.6-plus (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_256k_tokens: unset -> 3.9e-06
    • cache_creation_input_token_cost_above_256k_tokens: unset -> 1.625e-06
    • input_cost_per_token_above_256k_tokens: unset -> 1.3e-06
  • openrouter/qwen/qwen3.7-flash (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_32k_tokens: unset -> 4e-07
    • cache_read_input_token_cost_above_32k_tokens: unset -> 2e-08
    • cache_creation_input_token_cost_above_32k_tokens: unset -> 1.25e-07
    • input_cost_per_token_above_32k_tokens: unset -> 1e-07
  • openrouter/qwen/qwen3.7-plus (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token_above_256k_tokens: unset -> 3.84e-06
    • cache_read_input_token_cost_above_256k_tokens: unset -> 1.92e-07
    • cache_creation_input_token_cost_above_256k_tokens: unset -> 1.2e-06
    • input_cost_per_token_above_256k_tokens: unset -> 9.6e-07
  • openrouter/z-ai/glm-5.3 (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 2.0548e-06 -> 2.64e-06
    • cache_read_input_token_cost: 1.2142e-07 -> 1.56e-07
    • input_cost_per_token: 6.538e-07 -> 8.4e-07
  • openrouter/z-ai/glm-5.3-flashx (kind: api, source https://openrouter.ai/api/v1/models)
    • cache_read_input_token_cost: 7.5e-08 -> 9e-08
  • openrouter/z-ai/glm-5.3:batch (kind: api, source https://openrouter.ai/api/v1/models)
    • output_cost_per_token: 2.4e-06 -> 2e-06
    • cache_read_input_token_cost: 1.2e-07 -> 1e-07
    • input_cost_per_token: 7.2e-07 -> 4.5e-07

Delisted by the provider

None

Unpriced

None

Relevant issues

Affected release

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests (data only change, covered by the existing schema and cost map guard tests)
  • The handful of test files covering my change pass locally: python3 -m pytest tests/test_litellm/test_model_prices_schema.py tests/test_litellm/test_cost_map_guard.py -q (85 passed)
  • My PR passes all required CI/CD checks
  • 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

Screenshots / Proof of Fix

Data only sync from the provider list API; the evidence is the per row API values listed above

Type

🐛 Bug Fix

Caveats (if any)

Low

  • openrouter/tencent/hy3 off_peak_pricing was left as is: the API emits the same values the catalog already holds, only serialized differently
  • openrouter/deepseek/deepseek-v4.1-flash keeps its existing off_peak_pricing block; only the base prices moved

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

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

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.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR should not merge until the retained DeepSeek off-peak rates are reconciled with the newly synchronized base prices

Findings

  1. P1 Off-peak rates exceed peak ▶

Summary

This PR synchronizes OpenRouter token prices, adds Qwen long-context pricing tiers, and updates the generated pricing schema

  • Updates 18 OpenRouter model entries in both synchronized price maps
  • Adds 32k, 128k, and 256k Qwen input, output, and cache pricing tiers
  • Leaves two DeepSeek off-peak overrides inconsistent with their newly synchronized base prices

Reviews (1) · Last reviewed commit: "fix(models): sync openrouter prices from..."

Comment on lines +40270 to +40272
"input_cost_per_token": 1.4e-07,
"output_cost_per_token": 4.2e-07,
"cache_read_input_token_cost": 4.2e-09,

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.

P1 Off-peak rates exceed peak

During configured windows, these updated base rates are replaced by retained higher rates, overcharging both changed DeepSeek models

Knowledge Base Used: Spend, budgets, and rate limits

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_sync_openrouter (b50386c) with main (6c8afb2)1

Open in CodSpeed

Footnotes

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

…test

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.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.

1 participant