Skip to content

fix(pricing): correct gpt-5.6 prices for openai, bedrock, and flex long context - #35270

Merged
mateo-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_gpt_pricing_change
Jul 31, 2026
Merged

fix(pricing): correct gpt-5.6 prices for openai, bedrock, and flex long context#35270
mateo-berri merged 5 commits into
litellm_internal_stagingfrom
litellm_gpt_pricing_change

Conversation

@mubashir1osmani

@mubashir1osmani mubashir1osmani commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

TLDR

Problem this solves:

  • OpenAI cut GPT-5.6 Terra 20% and Luna 80% on 2026-07-30
  • Bedrock still billed the pre-cut rate; Luna overcharged 5x
  • flex requests above 272k billed 2x the published rate

How it solves it:

  • update the openai Terra and Luna entries
  • re-derive the bedrock_mantle Terra and Luna entries from AWS
  • add the flex long-context fields, and wire them through get_model_info

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 received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Pending; see the QA runbook below for the commands to run against a live proxy

Type

🐛 Bug Fix

Changes

Three separate problems, all in GPT-5.6 pricing.

The openai entries came first. Every cost field on gpt-5.6-terra and gpt-5.6-luna now matches https://developers.openai.com/api/docs/pricing across the Standard, Batch, Flex, and Fast (ex-Priority) tiers and both context columns. Terra is $2.00 in / $12.00 out, Luna is $0.20 in / $1.20 out per 1M, with cache writes at 1.25x input and cache reads at 0.1x. gpt-5.6-sol was not cut and its base prices are unchanged.

The bedrock_mantle entries were stale. They had been derived from the pre-cut base at a 1.375x (Terra) and 5.5x (Luna) uplift and never re-derived, so Terra billed $2.75/$16.50 and Luna billed $1.10/$6.60 against AWS's published $2.20/$13.20 and $0.22/$1.32; a 1.25x overcharge on Terra and 5x on Luna. AWS states in-region inference is priced at parity with OpenAI's data residency tier, so all three now sit at a consistent 1.1x over base. Sol already did, which is why it needed no change and corroborates the multiplier.

The flex long-context gap is the subtlest of the three. OpenAI publishes a long-context column on the Flex tier at half the standard long-context rate, but there was no field for it, so a >272k flex request fell back to the standard long-context price and billed double: Terra $4/$18 instead of $2/$9, Luna $0.40/$1.80 instead of $0.20/$0.90, Sol $10/$45 instead of $5/$22.50. Adding the numbers to the cost map is not enough on its own; get_model_info builds ModelInfoBase from an explicit kwargs list and silently drops any key not named there, so the four *_above_272k_tokens_flex fields are declared and wired through as well. Worth knowing for anyone adding pricing fields in future: a JSON-only change can look correct and do nothing.

Wiring that up surfaced a pre-existing instance of the same bug. cache_creation_input_token_cost_flex, cache_creation_input_token_cost_priority, and cache_creation_input_token_cost_above_272k_tokens were all present in the cost map but never reached the calculator; they are wired through here too.

Fast mode (ex-Priority) publishes no long-context column at all, so nothing is added there rather than deriving a rate by analogy from the 2x short-context relationship.

Azure is deliberately left at its pre-cut $2.50/$15.00 and $1.00/$6.00. Azure's pricing page lists the GPT-5.6 series but renders every figure as a placeholder dash because rates load per region and currency, so whether Microsoft passed the cut through is unconfirmed. Holding the old value risks overcharging; guessing the new one risks undercharging and diverging from the actual bill. Worth a follow-up from someone who can read the live page with a region selected.

tests/test_litellm/test_gpt_5_6_model_metadata.py is removed; its openai and Azure pricing assertions duplicate test_llm_cost_calc_utils.py, which still covers the Azure global and us/eu regional 1.1x rows.

One number to eyeball before merging: the AWS table labels its cache-write column "30m cache write". cache_creation_input_token_cost holds a single value and $2.75 / $0.275 is the 30-minute figure, consistent with the 1.25x-input convention used elsewhere.

QA runbook

Set LITELLM_LOCAL_MODEL_COST_MAP=True on the proxy before checking any of this. With it unset or false, litellm fetches the cost map over the network at import and ignores the local JSON, so a spot check reads the old prices and this branch looks like it changed nothing.

  • tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py::test_generic_cost_per_token_gpt56_flex_above_272k - a >272k flex request bills the flex long-context rate, which is half the standard long-context rate
    • Start the proxy: LITELLM_LOCAL_MODEL_COST_MAP=True python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml --detailed_debug --reload --use_v2_migration_resolver 2>&1 | tee litellm.log
    • Send a >272k-token flex request: curl -s http://localhost:4000/v1/chat/completions -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" -d "{\"model\": \"gpt-5.6-terra\", \"service_tier\": \"flex\", \"messages\": [{\"role\": \"user\", \"content\": \"$(python3 -c 'print("word "*300000)')\"}]}" | jq '{model, usage}'
    • Read the spend row back and expect prompt_tokens x $2/1M, i.e. half what it billed before this PR: curl -s "http://localhost:4000/spend/logs?request_id=<id>" -H "Authorization: Bearer sk-1234" | jq '.[0] | {model, spend, prompt_tokens, completion_tokens}'
    • Sanity check: this test makes sense to add and is not hand-wavey (it asserts the exact expected cost, and a mutation dropping the new plumbing makes all four parametrized cases fail)
  • Terra and Luna standard pricing after the cut
    • Send a short Terra call and a short Luna call without service_tier
    • Expect $2/$12 and $0.20/$1.20 per 1M in the spend rows
    • Sanity check: gpt-5.6-sol still bills $5/$30 per 1M, unchanged by this PR
  • bedrock_mantle Luna, the 5x overcharge
    • Send a /v1/responses call to a bedrock_mantle/openai.gpt-5.6-luna deployment
    • Expect $0.22/$1.32 per 1M; before this PR the same call billed $1.10/$6.60
    • Sanity check: bedrock_mantle/openai.gpt-5.6-sol is unchanged at $5.50/$33.00

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

mubashir1osmani and others added 2 commits July 30, 2026 13:06
@mubashir1osmani mubashir1osmani changed the title chore: placeholder for gpt pricing change fix: gpt-5.6-terra & luna pricing change Jul 30, 2026
@mubashir1osmani
mubashir1osmani marked this pull request as ready for review July 30, 2026 20:13
@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates GPT-5.6 pricing and carries new long-context Flex rates through cost calculation.

  • Corrects OpenAI Terra and Luna pricing across standard, batch, Flex, priority, cache, and long-context rates.
  • Updates Bedrock Mantle Terra and Luna pricing.
  • Adds long-context Flex pricing fields to model metadata, validation schemas, generated UI types, and model-info plumbing.
  • Adds focused cost-calculation and Bedrock pricing coverage while removing redundant metadata tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Updates GPT-5.6 OpenAI and Bedrock Mantle rates and defines Flex rates above the 272k-token threshold.
litellm/model_prices_and_context_window_backup.json Mirrors the GPT-5.6 pricing updates from the primary cost map.
litellm/types/utils.py Extends model-info and custom-pricing types with cache and token pricing fields for long-context Flex requests.
litellm/utils.py Preserves the newly supported pricing fields when constructing model metadata from the cost map.
model_prices_and_context_window.schema.json Adds numeric schema definitions for the new long-context Flex pricing fields.
tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py Updates GPT-5.6 expected rates and verifies Flex pricing for prompts above 272k tokens.
tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py Updates Bedrock Mantle GPT-5.6 pricing expectations.
tests/test_litellm/test_utils.py Extends model-cost validation coverage to the newly exposed pricing fields.

Reviews (3): Last reviewed commit: "fix(pricing): regenerate model prices sc..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread model_prices_and_context_window.json
@veria-ai

veria-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@mubashir1osmani
mubashir1osmani marked this pull request as draft July 30, 2026 20:18
…OpenAI's cut

AWS rolled out the 2026-07-30 GPT-5.6 price cut the same day, but the
bedrock_mantle entries still carried values derived from the pre-cut OpenAI
base, so Terra billed 1.25x and Luna 5x over the published rate.

Re-derive both from the AWS Bedrock pricing page, which prices in-region
inference at parity with OpenAI's data residency tier (1.1x base). Sol was
not cut and is unchanged.

Also drop tests/test_litellm/test_gpt_5_6_model_metadata.py; its Azure and
openai pricing assertions are covered by test_llm_cost_calc_utils.py.
@mubashir1osmani mubashir1osmani changed the title fix: gpt-5.6-terra & luna pricing change fix(pricing): correct gpt-5.6 terra/luna prices for openai and bedrock Jul 30, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_gpt_pricing_change (1c36f52) with litellm_internal_staging (81ff7cb)1

Open in CodSpeed

Footnotes

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

…context rate

OpenAI publishes a long-context column on the Flex tier, at half the standard
long-context rate. We had no field for it, so a >272k flex request fell through
to the standard long-context price and billed 2x: Terra $4/$18 instead of
$2/$9, Luna $0.40/$1.80 instead of $0.20/$0.90, Sol $10/$45 instead of $5/$22.50.

Adding the values to the cost map alone does nothing, because get_model_info
builds ModelInfoBase from an explicit kwargs list and silently drops any key
not named there. Declare the four *_above_272k_tokens_flex fields and wire them
through, then add the values for sol, terra, luna, and the gpt-5.6 alias.

That same gap was already swallowing cache_creation_input_token_cost_flex,
_priority, and _above_272k_tokens, which were present in the cost map but never
reached the calculator; they are wired through here too.

Fast mode (ex-Priority) publishes no long-context column, so nothing is added
there rather than deriving a rate by analogy.
@mubashir1osmani mubashir1osmani changed the title fix(pricing): correct gpt-5.6 terra/luna prices for openai and bedrock fix(pricing): correct gpt-5.6 prices for openai, bedrock, and flex long context Jul 30, 2026
@mateo-berri
mateo-berri marked this pull request as ready for review July 31, 2026 04:17
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri 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.

LGTM. Thanks!

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.

3 participants