Skip to content

fix(cost): bill Azure Foundry GPT-5.6 prompt cache writes - #35125

Open
omertal323 wants to merge 8 commits into
BerriAI:litellm_internal_stagingfrom
omertal323:litellm_azure_gpt56_cache_write_prices
Open

fix(cost): bill Azure Foundry GPT-5.6 prompt cache writes#35125
omertal323 wants to merge 8 commits into
BerriAI:litellm_internal_stagingfrom
omertal323:litellm_azure_gpt56_cache_write_prices

Conversation

@omertal323

@omertal323 omertal323 commented Jul 29, 2026

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Azure Foundry GPT-5.6 cache write tokens were billed at $0
  • Data-zone sol/gpt-5.6 priority writes were 25% above Azure's published cell

How it solves it:

  • Adds cache write prices to all 12 azure GPT-5.6 entries at 1.25x input
  • Sets data-zone sol/gpt-5.6 priority to Azure's $11 prompt / $13.75 write
  • Pins every added rate with cost-calculator regression tests

User Flow

Before: a developer whose Azure GPT-5.6 completion includes prompt-cache write tokens is billed as if those writes were free, so spend is only uncached input plus output

  1. They POST http://localhost:4000/spend/calculate with a completion_response for azure/gpt-5.6, 100000 prompt tokens, 80000 cache_write_tokens, and 10 completion tokens
  2. The response is {"cost":0.1003} (20000 uncached input x $5/1M + 10 output x $30/1M). The 80000 write tokens add $0
  3. The same payload for azure/us/gpt-5.6 with "service_tier":"priority" returns {"cost":0.275825}. Writes add $0
  4. The same payload for azure/gpt-5.6-luna returns {"cost":0.004012}. Writes add $0

After: the same payloads bill cache writes at 1.25x input. Data-zone sol/gpt-5.6 priority uses Azure's $11 / $13.75 cells. Luna writes stay on the 7/30 cut ($0.25/1M)

  1. They POST the same azure/gpt-5.6 payload. Response is {"cost":0.6003} (80000 writes x $6.25/1M = $0.50 added)
  2. They POST the same azure/us/gpt-5.6 priority payload. Response is {"cost":1.32066} (priority input $11/1M, writes $13.75/1M)
  3. They POST the same azure/gpt-5.6-luna payload. Response is {"cost":0.024012} (input $0.20/1M, writes $0.25/1M)

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
  • 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)

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

Azure added prompt cache write pricing for the GPT-5.6 series on 2026-07-29. Write is 1.25x the matching input cell. Sources disagree for terra/luna, so this PR does not treat the calculator API as the last word for those two

Sol (unchanged by the 7/30 cut): the calculator API still matches the Foundry blog. Global short write $6.25, data-zone short write $6.875, data-zone priority write $13.75 (language-models-gpt-5-6-sol-short-priority-area-cache-writes). Azure has no gpt-5-6 base offer; azure/gpt-5.6 mirrors sol

Terra and luna: the calculator still shows pre-cut cells (terra input $2.50 / luna $1.00). The Foundry launch blog says the table "reflects the latest discounts announced by OpenAI on 7/30" and lists Standard Global short as terra $2.00 / $2.50 write and luna $0.20 / $0.25 write. OpenAI's live list is the same. A Microsoft Q&A moderator (2026-08-11) and Azure Support (2026-08-10) say the cut applied on Azure from 2026-08-01 and that the public pricing page lags. This PR follows the blog for terra/luna, including 1.25x writes on those cut inputs, and #35481 for the input/output cells

We don't have an Azure GPT-5.6 deployment to burn real dollars on, so the proof uses /spend/calculate with the usage shape Azure returns. After proxy: LITELLM_LOCAL_MODEL_COST_MAP=True python -m litellm.proxy.proxy_cli --config litellm/proxy/dev_config.yaml --port 4001 at bcc2d54. Before was the same payload against a proxy still on the merge-base map (no cache-write fields)

Shared payload (model and optional service_tier vary per case):

curl -s http://localhost:4001/spend/calculate -H 'Authorization: Bearer sk-1234' -H 'Content-Type: application/json' -d '{
  "completion_response": {
    "id": "chatcmpl-proof",
    "object": "chat.completion",
    "created": 1753000000,
    "model": "azure/gpt-5.6",
    "choices": [{"index": 0, "message": {"role": "assistant", "content": "ok"}, "finish_reason": "stop"}],
    "usage": {
      "prompt_tokens": 100000,
      "completion_tokens": 10,
      "total_tokens": 100010,
      "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 80000}
    }
  }
}'

Before (d542c82)

Global azure/gpt-5.6 cache write

  1. POST /spend/calculate with model: azure/gpt-5.6 and the shared usage
  2. Observed: {"cost":0.1003}. 80000 write tokens add $0 (20000 uncached input x $5/1M + 10 output x $30/1M only)

Data-zone priority azure/us/gpt-5.6

  1. Same payload with model: azure/us/gpt-5.6 and "service_tier":"priority"
  2. Observed: {"cost":0.275825}. Writes add $0. Priority input is the stale $13.75/1M (Azure publishes $11)

Luna azure/gpt-5.6-luna

  1. Same payload with model: azure/gpt-5.6-luna
  2. Observed: {"cost":0.004012}. Writes add $0. Input is already the 7/30 cut ($0.20/1M)

After (bcc2d54)

Global azure/gpt-5.6 cache write

  1. Same POST against the branch proxy on port 4001
  2. Observed: {"cost":0.6003}. 80000 write tokens add $0.50 at Azure's published $6.25/1M

Data-zone priority azure/us/gpt-5.6

  1. Same priority payload against port 4001
  2. Observed: {"cost":1.32066}. Priority input $11/1M, writes $13.75/1M (Azure's gpt-5-6-sol-short-priority-area-* cells). An earlier revision of this PR billed those writes at $17.1875 by applying 1.25x to the stale $13.75 input

Luna azure/gpt-5.6-luna

  1. Same luna payload against port 4001
  2. Observed: {"cost":0.024012}. Input $0.20/1M, writes $0.25/1M (Foundry blog / OpenAI cut). Data-zone luna on the same payload is {"cost":0.0264132} at $0.22 / $0.275

Type

🐛 Bug Fix

Changes

Adds cache_creation_input_token_cost, cache_creation_input_token_cost_above_272k_tokens, and cache_creation_input_token_cost_priority (plus _above_272k_tokens_priority on the four global entries) to all 12 azure/gpt-5.6* entries in model_prices_and_context_window.json and the backup copy

Global and data-zone short/long writes for gpt-5.6 and -sol match Azure's published calculator cells ($6.25 / $12.50 global, $6.875 / $13.75 data zone). Data-zone priority for those two models was wrong on an earlier revision: 1.25x of our stale $13.75 priority input produced $17.1875, while Azure publishes $11 prompt and $13.75 write (language-models-gpt-5-6-sol-short-priority-area-*). This revision also corrects the data-zone priority input, cache-read, and output cells to that same Azure row ($11 / $1.10 / $66)

Luna and terra writes are 1.25x of the cut inputs from #35481, which match the Foundry blog's post-7/30 table (luna $0.25 / $0.275, terra $2.50 / $2.75). The calculator API still lists pre-cut luna $1.25 and terra $3.125 writes. Do not copy those back. Azure publishes no luna priority cells, so priority and long+priority luna rates stay inferred from the cut inputs

cache_creation_input_token_cost_above_272k_tokens_priority on the four global entries is inferred (1.25x of our long+priority input). Azure publishes no long+priority cell for any 5.6 variant. For us/eu entries, which also have no published long-context priority prices, the test pins the fallback to the standard long-context write rate. azure/gpt-5.6 mirrors sol. Azure has no gpt-5-6 base offer

An earlier revision of this PR also declared the cache_creation_input_token_cost_flex/_priority/_above_272k_tokens[_priority] fields in ModelInfoBase, without which get_model_info strips them and cache writes fall back to the standard rate. #35270 landed the same field declarations first, so after rebasing this PR carries only the pricing data, the regenerated prices schema, and the tests

Tests: test_generic_cost_per_token_azure_gpt_5_6_cache_write_tokens pins the write rates for all 12 azure entries across standard, priority, and long-context tiers through generic_cost_per_token. test_azure_data_zone_gpt56_priority_matches_azure_list pins the data-zone sol/gpt-5.6 priority row to Azure's $11 / $13.75 cells so the 1.25x-of-stale-input bug cannot return. test_generic_cost_per_token_azure_gpt56 pins terra/luna to the 7/30 cut. test_generic_cost_per_token_openai_gpt_5_6_cache_write_service_tiers pins the flex/priority plumbing via the OpenAI entry. The new _above_272k_tokens_priority key is on the intended-schema whitelist in tests/test_litellm/test_utils.py

Caveats (if any)

  • The calculator API still shows pre-cut terra ($2.50 input) and luna ($1.00 input). The Foundry blog, OpenAI list, and Azure Support say the 7/30 cut applies. Follow the blog for those two
  • Long+priority cache writes on the four global entries are inferred. Azure publishes no long+priority cell for any 5.6 variant
  • Azure has no gpt-5-6 base offer. azure/gpt-5.6 is sol rates
  • Luna priority / long+priority are inferred. Azure publishes no luna priority cells

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

Note

Medium Risk
Changes spend calculation for Azure GPT-5.6 (including previously free cache writes and lower data-zone priority rates). Wrong cells would systematically over- or under-bill customers.

Overview
Azure GPT-5.6 cache-write tokens were billed at $0. This adds cache_creation_input_token_cost (and long-context / priority variants) to all 12 azure/gpt-5.6* entries at 1.25x the matching input cell.

Also corrects US/EU data-zone priority rates for gpt-5.6/-sol: prompt $11/1M, cache-read $1.10/1M, output $66/1M, writes $13.75/1M (previously 2.5x input instead of Azure’s 2x). Global long+priority writes are inferred; data-zone long+priority falls back to the standard long write rate.

Schema whitelist now includes cache_creation_input_token_cost_above_272k_tokens_priority. Tests pin write billing across standard/priority/long context and OpenAI flex/priority cache-write plumbing.

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

@CLAassistant

CLAassistant commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py Outdated
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects Azure Foundry GPT-5.6 prompt-cache write billing and regional priority pricing

  • Adds standard, priority, and long-context cache-write rates for all 12 Azure GPT-5.6 pricing entries
  • Aligns US and EU GPT-5.6 and Sol priority input, cache-read, and output rates with the published data-zone pricing
  • Extends the pricing schema and regression tests for cache-write tier selection
  • Replaces the previously skipped regional long-priority case with an explicit fallback assertion

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 Adds Azure GPT-5.6 cache-write pricing and corrects data-zone GPT-5.6 and Sol priority rates
litellm/model_prices_and_context_window_backup.json Keeps the bundled backup pricing map synchronized with the canonical pricing data
model_prices_and_context_window.schema.json Declares the combined long-context priority cache-write pricing field
tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py Covers all Azure GPT-5.6 cache-write tiers, including explicit regional long-priority fallback behavior
tests/test_litellm/test_utils.py Updates pricing-map validation for the combined long-context priority cache-write field

Reviews (7): Last reviewed commit: "fix(cost): restore Azure GPT-5.6 luna to..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@omertal323

Copy link
Copy Markdown
Author

@greptileai

@codspeed-hq

codspeed-hq Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing omertal323:litellm_azure_gpt56_cache_write_prices (bcc2d54) with litellm_internal_staging (d542c82)1

Open in CodSpeed

Footnotes

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

@omertal323
omertal323 force-pushed the litellm_azure_gpt56_cache_write_prices branch from 92781c8 to ce74653 Compare August 1, 2026 17:05
@omertal323

Copy link
Copy Markdown
Author

@greptileai

@omertal323
omertal323 force-pushed the litellm_azure_gpt56_cache_write_prices branch from ce74653 to 0b4b171 Compare August 5, 2026 06:42
@omertal323

Copy link
Copy Markdown
Author

@greptileai

@omertal323

omertal323 commented Aug 5, 2026

Copy link
Copy Markdown
Author

@mubashir1osmani / @mateo-berri this complements your gpt-5.6 pricing work in #35481: azure cache writes for the 5.6 series currently bill at $0. This PR adds them for all 12 azure entries at the published rate (1.25x of input in every cell Azure lists), rebased on top of your terra/luna cut so the write prices track the new inputs. Greptile 5/5, tests pin every rate

Azure publishes prompt cache write pricing for the GPT-5.6 series
(gpt-5.6, -sol, -terra, -luna) at 1.25x the matching input rate, but the
azure/gpt-5.6* entries had no cache_creation_input_token_cost fields, so
cache write tokens were billed at 0.

Adds the cache write prices for all 12 azure GPT-5.6 entries (global,
us, and eu data zones) and declares the flex/priority/above-272k
cache_creation cost fields in ModelInfo so get_model_info stops
stripping them; the priority and long-context write rates already
present on the OpenAI gpt-5.6 entries were silently ignored for the
same reason.
@omertal323
omertal323 force-pushed the litellm_azure_gpt56_cache_write_prices branch from 0b4b171 to fb4aa63 Compare August 6, 2026 05:08
@omertal323

Copy link
Copy Markdown
Author

@greptileai

marty-sullivan added a commit to cu-aaii/litellm that referenced this pull request Aug 7, 2026
…shed rates

No azure/gpt-5.6* row carried cache_creation_input_token_cost, so cache-write
tokens billed at $0 while Azure charges for them. Azure's retail meters publish
"Cd Wr" rates for the whole family: $6.25/1M for the base alias and sol, $3.125
for terra, $1.25 for luna, with LongCo (above 272k) at 2x and Priority
Processing at 2x, and Data Zone at 1.1x for the azure/us and azure/eu rows.
Values are identical in eastus2, westus3 and swedencentral, all effective
2026-07-01 as a single version.

above_272k_tokens_priority has no published meter, so it is 2x the LongCo
Standard rate, which is both Azure's exact PP multiplier everywhere it is
published and the extrapolation the cache_read_* fields in these same rows
already use. The global rows get all four tier variants and the us/eu rows get
three, mirroring the field set each row already has for input, output and cache
read rather than inventing a uniform shape.

Deliberately does NOT take upstream's numbers. Upstream BerriAI#35125 proposes the same
fields but sources terra and luna from OpenAI's post-cut direct prices ($2.50 and
$0.25) rather than Azure's meters, and derives the data-zone priority fields with
a 2.5x multiplier where Azure publishes exactly 2x. Reported as BerriAI#36192, together
with the already-merged BerriAI#35481 that applied OpenAI's terra/luna token-price cut
to the azure rows Azure never cut.
marty-sullivan added a commit to cu-aaii/litellm that referenced this pull request Aug 7, 2026
…ates

The cherry-pick of upstream 4d43080 lowered the terra and luna token prices
to OpenAI's post-cut rates but left cache writes at the values sourced from
Azure's retail meters, which broke the family's cache-write ratio: cache write
is 1.25x the input price for every gpt-5.6 variant on both Azure's meters and
Microsoft's published table, yet terra came out at 1.563x and luna at 6.250x.
Luna billing cache writes at 6.25x its input rate is not a defensible reading of
either source, so the two columns have to come from the same basis.

Scales the cache_creation fields on the six azure terra/luna rows by the same
0.8 and 0.2 the token prices already took: terra $3.125 -> $2.50 and luna $1.25
-> $0.25 per 1M global, data zone staying at 1.1x. Sol and the azure/gpt-5.6
base alias are untouched; neither vendor cut them and both already sat at 1.25x.

Done as a direct edit rather than a cherry-pick because no upstream commit makes
this change. Upstream BerriAI#35125 proposes the same terra and luna cache-write values
but is still open, would conflict with the fields added here in 5eadb9b, and
derives the data-zone _priority fields with a 2.5x multiplier where this family's
Priority Processing meters are exactly 2x, which would put azure/us/gpt-5.6 at
$17.1875 against a published $13.75.

Verified the resulting azure global cache-write values equal upstream/main's
openai rows for the same models, which is an independent check since azure
global tracks openai direct under this basis; that the 1.25x ratio holds on all
eight rows; that data zone stays 1.1x; and that generic_cost_per_token bills
each row at the intended rate.
@omertal323

Copy link
Copy Markdown
Author

@mateo-berri any chance for a review here?

Data-zone sol/gpt-5.6 priority cache writes were 1.25x of a stale $13.75
priority input. Azure publishes $11 prompt and $13.75 write. Luna was 5x
under Azure list because input/read already tracked OpenAI's cut.

Terra writes still follow the OpenAI cut from BerriAI#35481.
@mubashir1osmani

Copy link
Copy Markdown
Contributor

Pushed a follow-up: data-zone priority writes are now $13.75/1M, luna tracks Azure list. @greptileai

TQ004 counts raw os.environ writes against the test-quality budget. Use
the existing _local_model_cost_map fixture so the env and model_cost
restore at teardown.
The openai-service calculator still lists pre-cut luna ($1/$6, writes
$1.25). Microsoft's Foundry blog, OpenAI's live list, and Azure Support
all put Standard Global luna at $0.20/$1.20 with $0.25 writes after the
2026-07-30 cut, effective on Azure from 2026-08-01. Reverting the luna
cells undoes the 5x overbill. Data-zone sol/gpt-5.6 priority stays at
Azure's $11 prompt / $13.75 write
@mubashir1osmani

Copy link
Copy Markdown
Contributor

Reverted luna to the 7/30 Foundry cut ($0.25 writes). Data-zone sol priority stays at $13.75. @greptileai

@mubashir1osmani

Copy link
Copy Markdown
Contributor

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 bcc2d54. Configure here.

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