Skip to content

fix(pricing): add missing Azure gpt-5.6 cache-write rates - #38187

Closed
jlan-nl wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
jlan-nl:litellm-azure-gpt56-cache-write-pricing
Closed

fix(pricing): add missing Azure gpt-5.6 cache-write rates#38187
jlan-nl wants to merge 1 commit into
BerriAI:litellm_internal_stagingfrom
jlan-nl:litellm-azure-gpt56-cache-write-pricing

Conversation

@jlan-nl

@jlan-nl jlan-nl commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Azure gpt-5.6 cache-write tokens are billed at zero
  • Spend under-reported by ~98% on cache-heavy prompts

How it solves it:

  • Adds the missing cache-write rate to 12 azure gpt-5.6 entries
  • Derives each from the OpenAI twin's cache-to-input ratio

User Flow

Before: a platform team charging back Azure OpenAI spend sees almost nothing billed for their RAG service, whose requests carry a large cached system prompt

  1. Their RAG service sends POST https://litellm-domain/v1/chat/completions with "model": "azure-gpt-5.6-sol" and a ~2,200-token system prompt
  2. The response comes back 200 with "usage": {"prompt_tokens": 2219, "completion_tokens": 5, "prompt_tokens_details": {"cached_tokens": 0, "cache_write_tokens": 2216}}
  3. They open https://litellm-domain/ui/?page=logs and the request shows $0.000165 spend, as if the 2,216 cache-write tokens were free
  4. Their monthly Azure invoice for that traffic is roughly 85x the total the gateway reports, so per-team chargeback is unusable

After: the same request is billed at the cache-write rate, and the gateway total lines up with the invoice

  1. Their RAG service sends the same POST https://litellm-domain/v1/chat/completions with "model": "azure-gpt-5.6-sol" and the same ~2,200-token system prompt
  2. The response comes back 200 with the same usage object
  3. https://litellm-domain/ui/?page=logs now shows that request at $0.014015 spend
  4. The monthly total tracks the Azure invoice, so chargeback per team is accurate

Relevant issues

Fixes #37631

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)

Screenshots / Proof of Fix

Shared setup, a live Azure OpenAI gpt-5.6-sol deployment behind the proxy:

model_list:
  - model_name: azure-gpt-5.6-sol
    litellm_params:
      model: azure/gpt-5.6-sol
      api_base: os.environ/AZURE_OPENAI_ENDPOINT
      api_version: "2025-04-01-preview"

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: os.environ/DATABASE_URL

The request body, sized so the prompt is large enough for Azure to write it to cache:

python - <<'EOF'
import json
prefix = 'You are a documentation assistant. ' + (
    'The following is reference material about cloud architecture patterns. ' * 220)
json.dump({"model": "azure-gpt-5.6-sol",
           "messages": [{"role": "system", "content": prefix},
                        {"role": "user", "content": "say ok"}],
           "max_tokens": 10}, open("req.json", "w"))
EOF

Before (31a6756)

  1. Start the proxy at the merge base and send the request, confirming the provider reports cache writes:
curl -s http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" --data @req.json | jq .usage
  1. Read back what the gateway recorded for it:
curl -s "http://localhost:4000/spend/logs" \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" | jq '.[-1] | {model, spend, prompt_tokens}'

Expected to show the cache-write tokens costing nothing, around $0.000165 against a correct $0.014015

After (0400f0b)

  1. Restart the proxy at this PR's tip and send the identical request:
curl -s http://localhost:4000/v1/chat/completions \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" \
  -H "Content-Type: application/json" --data @req.json | jq .usage
  1. Read back the recorded spend:
curl -s "http://localhost:4000/spend/logs" \
  -H "Authorization: Bearer $LITELLM_MASTER_KEY" | jq '.[-1] | {model, spend, prompt_tokens}'

Expected to show the same usage object now billed at the cache-write rate, around $0.014015

Both runs are pending: no Azure gpt-5.6 deployment was available to whoever prepared this branch, so the output above is stated as an expectation rather than a captured run. The commands are ready to paste and this section will be replaced with the real output before review. In the meantime the regression test in tests/test_litellm/test_cost_calculator.py covers the same billing path, and every one of its 37 cases fails at the merge base and passes here

Type

🐛 Bug Fix

✅ Test

Caveats (if any)

  • Purely additive: no existing price is modified
  • Azure priority input rates look wrong, but that is separate
  • Also fixes the azure/eu entries, which the issue omits

@jlan-nl
jlan-nl requested a review from mateo-berri as a code owner August 25, 2026 07:51
@CLAassistant

CLAassistant commented Aug 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds cache-write pricing for 12 Azure GPT-5.6 model entries so cached prompt creation is included in spend calculations

  • Adds global, EU, and US cache-creation rates for standard, long-context, and priority tiers
  • Keeps the primary and backup model-price catalogs synchronized
  • Adds metadata consistency and end-to-end cost-calculator regression coverage

Confidence Score: 5/5

The PR appears safe to merge, with consistent pricing metadata and focused regression coverage

All affected Azure GPT-5.6 variants receive cache-creation rates derived consistently from their corresponding input rates, both catalogs remain synchronized, and the billing path is exercised

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds internally consistent cache-creation rates to all 12 affected Azure GPT-5.6 entries
litellm/model_prices_and_context_window_backup.json Mirrors the primary pricing-catalog changes without divergence
tests/test_litellm/test_cost_calculator.py Verifies every added rate against its OpenAI twin and exercises cache-write billing through the generic calculator

Reviews (1): Last reviewed commit: "fix(pricing): add missing Azure gpt-5.6 ..." | 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!

Azure bills the first write of a prompt into its cache at 1.25x the input
rate, but none of the azure/* gpt-5.6 entries carried
cache_creation_input_token_cost. Since v1.97.0 LiteLLM classifies Azure's
cache_write_tokens as cache-creation tokens, so the lookup found no rate and
billed them at $0, under-billing a write-heavy prompt by ~98%.

Fills the field on all 12 entries (azure/, azure/eu/ and azure/us/ across
gpt-5.6, -sol, -terra and -luna) for the base, above-272k and priority tiers.
Each value is derived from the Azure input rate times the OpenAI twin's
cache-to-input ratio, so the 10% regional uplift on azure/eu and azure/us is
preserved rather than flattened to the global number.

Fixes BerriAI#37631
@jlan-nl
jlan-nl force-pushed the litellm-azure-gpt56-cache-write-pricing branch from c08aab1 to 0400f0b Compare August 25, 2026 08:25
@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 jlan-nl:litellm-azure-gpt56-cache-write-pricing (0400f0b) with litellm_internal_staging (31a6756)

Open in CodSpeed

@jlan-nl

jlan-nl commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing, superseded by #38370

@jlan-nl jlan-nl closed this Aug 27, 2026
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.

[Bug]: azure/gpt-5.6* entries missing cache_creation_input_token_cost — cache writes billed at zero since v1.97.0

2 participants