fix(cost): bill Azure Foundry GPT-5.6 prompt cache writes - #35125
fix(cost): bill Azure Foundry GPT-5.6 prompt cache writes#35125omertal323 wants to merge 8 commits into
Conversation
Greptile SummaryThis PR corrects Azure Foundry GPT-5.6 prompt-cache write billing and regional priority pricing
Confidence Score: 5/5The PR appears safe to merge No blocking failure remains
|
| 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
92781c8 to
ce74653
Compare
ce74653 to
0b4b171
Compare
|
@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.
…y in prices schema whitelist
0b4b171 to
fb4aa63
Compare
…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.
…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.
|
@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.
|
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
|
Reverted luna to the 7/30 Foundry cut ($0.25 writes). Data-zone sol priority stays at $13.75. @greptileai |
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
TLDR
Problem this solves:
How it solves it:
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
azure/gpt-5.6, 100000 prompt tokens, 80000cache_write_tokens, and 10 completion tokens{"cost":0.1003}(20000 uncached input x $5/1M + 10 output x $30/1M). The 80000 write tokens add $0azure/us/gpt-5.6with"service_tier":"priority"returns{"cost":0.275825}. Writes add $0azure/gpt-5.6-lunareturns{"cost":0.004012}. Writes add $0After: 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)
azure/gpt-5.6payload. Response is{"cost":0.6003}(80000 writes x $6.25/1M = $0.50 added)azure/us/gpt-5.6priority payload. Response is{"cost":1.32066}(priority input $11/1M, writes $13.75/1M)azure/gpt-5.6-lunapayload. 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
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@greptileaito 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.6mirrors solTerra 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/calculatewith 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 4001at 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_tiervary per case):Before (d542c82)
Global azure/gpt-5.6 cache write
/spend/calculatewithmodel: azure/gpt-5.6and the shared usage{"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
model: azure/us/gpt-5.6and"service_tier":"priority"{"cost":0.275825}. Writes add $0. Priority input is the stale $13.75/1M (Azure publishes $11)Luna azure/gpt-5.6-luna
model: azure/gpt-5.6-luna{"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
{"cost":0.6003}. 80000 write tokens add $0.50 at Azure's published $6.25/1MData-zone priority azure/us/gpt-5.6
{"cost":1.32066}. Priority input $11/1M, writes $13.75/1M (Azure'sgpt-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 inputLuna azure/gpt-5.6-luna
{"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.275Type
🐛 Bug Fix
Changes
Adds
cache_creation_input_token_cost,cache_creation_input_token_cost_above_272k_tokens, andcache_creation_input_token_cost_priority(plus_above_272k_tokens_priorityon the four global entries) to all 12azure/gpt-5.6*entries inmodel_prices_and_context_window.jsonand the backup copyGlobal 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_priorityon 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.6mirrors sol. Azure has no gpt-5-6 base offerAn earlier revision of this PR also declared the
cache_creation_input_token_cost_flex/_priority/_above_272k_tokens[_priority]fields inModelInfoBase, without whichget_model_infostrips 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 testsTests:
test_generic_cost_per_token_azure_gpt_5_6_cache_write_tokenspins the write rates for all 12 azure entries across standard, priority, and long-context tiers throughgeneric_cost_per_token.test_azure_data_zone_gpt56_priority_matches_azure_listpins 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_gpt56pins terra/luna to the 7/30 cut.test_generic_cost_per_token_openai_gpt_5_6_cache_write_service_tierspins the flex/priority plumbing via the OpenAI entry. The new_above_272k_tokens_prioritykey is on the intended-schema whitelist intests/test_litellm/test_utils.pyCaveats (if any)
azure/gpt-5.6is sol ratesFinal Attestation
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 12azure/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.