Skip to content

fix(pricing): add azure gpt-5.6 cache write rates and correct data zone priority - #38370

Merged
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_azure_gpt_5_6_cache_write_pricing
Aug 26, 2026
Merged

fix(pricing): add azure gpt-5.6 cache write rates and correct data zone priority#38370
mateo-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_azure_gpt_5_6_cache_write_pricing

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Azure returns gpt-5.6 cache writes as cache_write_tokens, and bills them at 1.25x input
  • Our 12 azure gpt-5.6 entries carry no cache write rate, so those tokens are billed at $0
  • azure/us and azure/eu priority rates sit at 1.25x Global; Azure's price page says 1.1x

How it solves it:

  • Adds cache_creation_input_token_cost (1.25x input) to every tier variant of all 12 entries
  • Corrects us/eu priority input, output, and cache read rates to 1.1x Global
  • Adds the missing us/eu above-272k priority rates, also at 1.1x Global
  • Regression tests pin both invariants against the Azure price page

User Flow

Before: a developer running an agent workload on an azure gpt-5.6-luna deployment sees gateway spend far below their Azure bill, because every prompt cache write is billed at $0

  1. They send POST https://litellm-domain/v1/chat/completions with {"model": "azure-gpt-5.6-luna", ...} and a long system prompt
  2. The response usage shows prompt_tokens_details.cache_write_tokens: 1313, which Azure bills at $0.25 per million tokens
  3. The x-litellm-response-cost-input header reads $0.0000006: only the 3 non-cached tokens were priced, the 1313 cache-write tokens cost $0
  4. An admin who pinned the Data Zone entry with priority processing sees the opposite error: priority tokens priced at 1.25x Global where Azure bills 1.1x

After: the same requests price cache writes and Data Zone priority exactly as the Azure price page does

  1. They send the same POST https://litellm-domain/v1/chat/completions with {"model": "azure-gpt-5.6-luna", ...} and the same long system prompt
  2. The response usage again shows prompt_tokens_details.cache_write_tokens: 1313
  3. The x-litellm-response-cost-input header now reads about $0.000329: 3 tokens at $0.20/M plus 1313 cache-write tokens at $0.25/M
  4. Data Zone priority requests are priced at 1.1x the Global rate, matching Azure's page

Relevant issues

Fixes #37631
Fixes #37268

Linear ticket

Resolves LIT-6178

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • 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)

Screenshots / Proof of Fix

Live proxy A/B against a real Azure Foundry gpt-5.6-luna deployment, both legs booted with --num_workers 2 and LITELLM_LOCAL_MODEL_COST_MAP=True: before at the merge base 95285c3, after at this PR's tip b349b9b. Five cases per leg, identical flow: a ~1300-token system prompt led by a fresh random cache-buster forces a cache WRITE on each of /v1/chat/completions, /v1/messages, and /v1/responses, repeating the chat prompt gets the cache READ, and a short prompt is the no-cache control. Azure's published Luna rates: input 2e-07, cache write 2.5e-07 (1.25x input), cache read 2e-08, output 1.2e-06

Exemplar request (same shape on both legs, only the port and buster differ):

curl -sD h.txt -o b.json -H 'Authorization: Bearer sk-lit6178' -H 'Content-Type: application/json' \
  -d @chat_write.json http://localhost:<port>/v1/chat/completions
grep -i x-litellm-response-cost h.txt; jq .usage b.json

Before (95285c3): cache-write tokens billed $0

chat_write came back with "prompt_tokens": 1703, "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 1700, ...} and

x-litellm-response-cost: 6.6e-06
x-litellm-response-cost-input: 6e-07
x-litellm-response-cost-output: 6e-06

cost-input 6e-07 is exactly the 3 uncached text tokens at 2e-07; the 1700 cache-write tokens contributed $0. The published-rate input side is 3 x 2e-07 + 1700 x 2.5e-07 = 4.256e-04, a ~650x input-side underbill. Same story on every write surface:

case endpoint write toks read toks cost-input observed input side at published rates
chat_write /v1/chat/completions 1700 0 6e-07 4.256e-04
chat_read /v1/chat/completions 0 1700 6e-07 + 3.4e-05 cache-read matches (read already priced)
msgs_write /v1/messages 1696 0 6e-07 4.246e-04
resp_write /v1/responses 1698 0 6e-07 4.251e-04
chat_short /v1/chat/completions 0 0 1.8e-06 matches

After (b349b9b): cache writes billed at 2.5e-07, exact

chat_write came back with 1627 cache-write tokens and

x-litellm-response-cost: 0.00041335
x-litellm-response-cost-input: 6.000000000000146e-07
x-litellm-response-cost-cache-creation: 0.00040675
x-litellm-response-cost-output: 6e-06

1627 x 2.5e-07 = 4.0675e-04, exactly the cache-creation amount. Every case matches the published-rate arithmetic:

case endpoint write toks read toks observed input-side cost expected
chat_write /v1/chat/completions 1627 0 6e-07 + 4.0675e-04 exact
chat_read (hit) /v1/chat/completions 0 1627 6e-07 + 3.254e-05 cache-read exact (1627 x 2e-08)
msgs_write /v1/messages 1626 0 6e-07 + 4.065e-04 exact
resp_write /v1/responses 1627 0 6e-07 + 4.0675e-04 exact
chat_short /v1/chat/completions 0 0 1.8e-06 exact

The first chat_read attempt (2s after the write) was a server-side cache miss, reported as a second write, and billed as one at 2.5e-07, correctly; the 10s retry hit the cache

Observations from the legs (all pre-existing, this PR leaves them alone):

  • Input cost splits across three response-cost headers
  • First cache-read attempt after 2s missed; 10s retry hit
  • /v1/messages usage keeps cache writes outside input_tokens
  • Chat usage reports both cache_write_tokens and cache_creation_tokens
  • Azure Luna returns a latency_checkpoint block in usage

Commits since this run: 8d750a2 only regenerates model_prices_and_context_window.schema.json (a generated file consumed by CI validation alone), e97a84a only adds the us/eu above-272k priority rates plus a stricter key-set test, and c5e3b21 only adds that key name to the test-side schema. The QA cases are all sub-272k standard-tier requests, so none of these commits change any behavior they exercise and the proof above stands; the above-272k priority path is pinned by the regression tests against the Azure price page.

Type

🐛 Bug Fix

Caveats (if any)

Low

  • Global long-context priority rates predate this PR and have no public page value; cache writes there follow the same 1.25x rule
  • Dated snapshot entries (e.g. gpt-5.6-luna-2026-07-09) and azure_ai gpt-5.6 entries are still missing; tracked separately

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

  • b349b9b passes /live-pr-risk

  • 8d750a2 passes /live-pr-risk

  • e97a84a passes /live-pr-risk

  • c5e3b21 passes /live-pr-risk


Note

Medium Risk
Changes only static pricing metadata but directly affects reported spend and budgets for Azure GPT-5.6 cache writes and Data Zone priority; incorrect rates would under- or over-bill customers.

Overview
Fixes Azure GPT-5.6 cost map entries so prompt cache-write tokens and US/EU Data Zone tiers match Azure’s published pricing.

All 12 azure/.../gpt-5.6* variants (global, sol, terra, luna × global/us/eu) now define cache_creation_input_token_cost (and matching priority / above-272k suffix keys) at 1.25× the corresponding input rate, so cache_creation_input_tokens / cache-write usage is no longer priced at $0 or at plain input when the calculator reads model_prices_and_context_window.json.

For azure/us/ and azure/eu/ entries, priority (and newly filled above-272k priority) input, output, cache-read, and cache-creation rates are corrected from an erroneous 1.25× Global to 1.1× Global, aligned with the Data Zone uplift on standard tiers.

The JSON schema gains cache_creation_input_token_cost_above_272k_tokens_priority, and regression tests assert cache-write billing for azure/gpt-5.6-luna plus map invariants across all twelve keys.

Reviewed by Cursor Bugbot for commit c5e3b21. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects Azure GPT-5.6 cache-write and Data Zone priority pricing metadata.

  • Adds cache-creation rates across all twelve Azure GPT-5.6 variants.
  • Adds the combined above-272k priority rates that the cost resolver selects for long priority requests.
  • Keeps the primary and backup pricing maps synchronized and extends the generated schema.
  • Adds regression coverage for cache-write billing and regional/global rate parity.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported combined cache-rate omission is fixed in both pricing maps and the runtime resolver selects the newly supplied field.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds the complete cache-write pricing ladder and corrects US/EU priority rates; the previously missing combined key is present across all affected entries.
litellm/model_prices_and_context_window_backup.json Mirrors the corrected Azure GPT-5.6 rates and combined long-context priority keys from the primary pricing map.
model_prices_and_context_window.schema.json Adds schema support for the combined above-272k priority cache-creation field.
tests/test_litellm/test_cost_calculator.py Adds cache-write cost and pricing-map invariant tests covering all twelve Azure GPT-5.6 variants.
tests/test_litellm/test_utils.py Extends the test-side pricing schema to recognize the new combined cache-creation rate key.

Reviews (4): Last reviewed commit: "test(utils): add priority cache write ti..." | Re-trigger Greptile

Comment thread model_prices_and_context_window.json
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot 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.

✅ 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 c5e3b21. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri
mateo-berri enabled auto-merge August 26, 2026 19:17
@mateo-berri
mateo-berri merged commit 74b6149 into litellm_internal_staging Aug 26, 2026
82 checks passed
@mateo-berri
mateo-berri deleted the litellm_azure_gpt_5_6_cache_write_pricing branch August 26, 2026 19:21
@codspeed-hq

codspeed-hq Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_azure_gpt_5_6_cache_write_pricing (c5e3b21) with litellm_internal_staging (cdb60af)1

Open in CodSpeed

Footnotes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants