Skip to content

fix(pricing): store per-token costs per token, not per 1k or per 1M - #38167

Closed
DivyaNarahari97 wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
DivyaNarahari97:litellm_fix_per_token_price_units
Closed

fix(pricing): store per-token costs per token, not per 1k or per 1M#38167
DivyaNarahari97 wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
DivyaNarahari97:litellm_fix_per_token_price_units

Conversation

@DivyaNarahari97

@DivyaNarahari97 DivyaNarahari97 commented Aug 25, 2026

Copy link
Copy Markdown

model_prices_and_context_window.json documents input_cost_per_token as "USD per prompt token", but 16 entries hold the vendor's quoted figure at its published unit instead.

Thirteen wandb/* entries carry W&B's per-1M-token price scaled by 1e5 too little, so wandb/openai/gpt-oss-120b billed $15,000 per 1M input tokens rather than $0.15. Every other provider's gpt-oss-120b sits at 1.5e-07, and the two wandb entries added later (Kimi-K2.5, MiniMax-M2.5) already use the per-token unit, so the ratio is a straight unit mistake rather than W&B being expensive.

azure_ai/jais-30b-chat holds Azure's per-1,000-token price ($0.0032 in, $0.00971 out), 1000x high. watsonx/bigscience/mt0-xxl-13b and watsonx/core42/jais-13b-chat both sat at 0.0005/0.002 while every other watsonx model is 1e-07 to 3e-06; IBM prices both at $1.80 per 1M tokens, matching watsonx/sdaia/allam-1-13b-instruct's existing 1.8e-06.

Cost tracking, budgets and the x-litellm-response-cost header all read these fields, so a session budget on any of these models tripped on the first request instead of the ten-thousandth.

The magnitude guard in test_model_prices_schema.py fails on all 30 of the bad values before this change, and covers every USD-per-token field in both the main map and the backup copy the SDK falls back to.

User Flow

Relevant issues

Linear ticket

model_prices_and_context_window.json documents input_cost_per_token as
"USD per prompt token", but 16 entries hold the vendor's quoted figure at
its published unit instead.

Thirteen wandb/* entries carry W&B's per-1M-token price scaled by 1e5 too
little, so wandb/openai/gpt-oss-120b billed $15,000 per 1M input tokens
rather than $0.15. Every other provider's gpt-oss-120b sits at 1.5e-07,
and the two wandb entries added later (Kimi-K2.5, MiniMax-M2.5) already
use the per-token unit, so the ratio is a straight unit mistake rather
than W&B being expensive.

azure_ai/jais-30b-chat holds Azure's per-1,000-token price ($0.0032 in,
$0.00971 out), 1000x high. watsonx/bigscience/mt0-xxl-13b and
watsonx/core42/jais-13b-chat both sat at 0.0005/0.002 while every other
watsonx model is 1e-07 to 3e-06; IBM prices both at $1.80 per 1M tokens,
matching watsonx/sdaia/allam-1-13b-instruct's existing 1.8e-06.

Cost tracking, budgets and the x-litellm-response-cost header all read
these fields, so a session budget on any of these models tripped on the
first request instead of the ten-thousandth.

The magnitude guard in test_model_prices_schema.py fails on all 30 of the
bad values before this change, and covers every USD-per-token field in
both the main map and the backup copy the SDK falls back to.
@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 Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Corrects mis-scaled per-token pricing metadata and adds regression coverage for pricing units.

  • Normalizes Azure AI, W&B, and watsonx token costs.
  • Synchronizes the primary and backup pricing maps.
  • Expands exact W&B pricing assertions.
  • Adds a magnitude guard for USD-per-token fields.

Confidence Score: 5/5

The PR appears safe to merge, with synchronized pricing corrections and focused regression coverage.

The changed price maps remain synchronized, the W&B expectations directly cover the corrected entries, and the schema guard checks both runtime pricing sources without introducing network dependencies.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Corrects per-token prices for affected Azure AI, W&B, and watsonx models without changing their metadata contracts.
litellm/model_prices_and_context_window_backup.json Mirrors the primary pricing-map corrections so fallback pricing remains synchronized.
tests/test_litellm/test_cost_calculator.py Adds exact expected prices for thirteen corrected W&B model entries without weakening existing assertions.
tests/test_litellm/test_model_prices_schema.py Adds a local-file regression test that rejects implausibly large numeric USD-per-token values in both pricing maps.

Reviews (1): Last reviewed commit: "fix(pricing): store per-token costs per ..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing DivyaNarahari97:litellm_fix_per_token_price_units (575f576) with litellm_internal_staging (fde3075)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (8f6de53) during the generation of this report, so fde3075 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Superseded by the rolling registry PR #39388, which re-verified these rows against the official pricing pages and absorbed the confirmed ones.

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