Skip to content

fix(pricing): add missing cache_read_input_token_cost to azure/us/ and azure/eu/ gpt-4o-2024-11-20 - #37830

Closed
AbhAy120204 wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
AbhAy120204:litellm_fix_azure_gpt4o_cache_read
Closed

AbhAy120204 wants to merge 2 commits into
BerriAI:litellm_internal_stagingfrom
AbhAy120204:litellm_fix_azure_gpt4o_cache_read

Conversation

@AbhAy120204

@AbhAy120204 AbhAy120204 commented Aug 21, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • azure/us/gpt-4o-2024-11-20 and azure/eu/gpt-4o-2024-11-20 missing cache_read_input_token_cost
  • Cache-read tokens on those deployments billed at $0 instead of the correct rate

How it solves it:

  • Adds cache_read_input_token_cost: 1.375e-06 to both entries
  • Matches the 1.1x data-zone uplift already on every other azure/us/ and azure/eu/ gpt-4o entry

User Flow

Before: a team using azure/us/gpt-4o-2024-11-20 with a large cached system prompt sees cache reads billed at zero

  1. They POST https://litellm-domain/v1/chat/completions with model: azure/us/gpt-4o-2024-11-20 and a prompt containing a large previously-cached block
  2. Azure returns usage with prompt_tokens_details.cached_tokens: 5000
  3. They open https://litellm-domain/ui/?page=logs and see the request logged at spend that excludes cache-read tokens: $0 instead of ~$0.007

After: the same request is billed correctly

  1. Same request
  2. Same Azure response with prompt_tokens_details.cached_tokens: 5000
  3. https://litellm-domain/ui/?page=logs shows the request at full spend including cache-read tokens at 1.375e-06/token (~$0.007)

Relevant issues

Fixes #37823

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 — local Python 3.10 env blocks litellm import (NotRequired missing from typing); delegating to CI
  • 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

This fix is a data correction with no provider API call involved. The proof is the price map values before and after.

Shared setup: run python -c "import json; d=json.load(open('model_prices_and_context_window.json')); [print(k, d[k].get('cache_read_input_token_cost')) for k in ['azure/us/gpt-4o-2024-11-20','azure/eu/gpt-4o-2024-11-20','azure/us/gpt-4o-2024-08-06']]" at the repo root

Before (ff02d5c)

  1. Command output:
    azure/us/gpt-4o-2024-11-20 None
    azure/eu/gpt-4o-2024-11-20 None
    azure/us/gpt-4o-2024-08-06 1.375e-06
    
  2. azure/us/ and azure/eu/ return None for cache_read while the same-family azure/us/gpt-4o-2024-08-06 returns the correct 1.375e-06

After (d80663a)

  1. Command output:
    azure/us/gpt-4o-2024-11-20 1.375e-06
    azure/eu/gpt-4o-2024-11-20 1.375e-06
    azure/us/gpt-4o-2024-08-06 1.375e-06
    
  2. All three entries now return the same value; cache-read tokens on these deployments are no longer billed at $0

Type

🐛 Bug Fix

Caveats (if any)

  • azure/gpt-4o-2024-11-20 (non-regional) already had cache_read_input_token_cost: 1.25e-06 (OpenAI rate, no uplift) and is not changed

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

…d azure/eu/ gpt-4o-2024-11-20

azure/us/gpt-4o-2024-11-20 and azure/eu/gpt-4o-2024-11-20 were missing
cache_read_input_token_cost, causing cache-read tokens to be billed at $0.
Every other azure data-zone gpt-4o entry applies the standard 1.1x uplift
over the OpenAI rate (1.25e-06 -> 1.375e-06); these two entries now match.

Fixes BerriAI#37823
@CLAassistant

CLAassistant commented Aug 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR corrects cached-token billing for the Azure US and EU GPT-4o 2024-11-20 entries.

  • Adds the regional cache_read_input_token_cost to the canonical and backup pricing maps.
  • Adds a focused regression test covering both model identifiers and the resulting cached-token cost calculation.

Confidence Score: 5/5

The PR appears safe to merge, with the corrected rates matching established regional pricing and covered by a focused regression test.

The canonical and fallback price maps remain synchronized, the new rate matches both Azure US/EU sibling entries, and the test exercises the cached-token billing path for both affected models.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds the correct 1.375e-06 cache-read rate to both regional model entries, consistent with neighboring Azure data-zone pricing.
litellm/model_prices_and_context_window_backup.json Keeps the fallback pricing map synchronized with the canonical map.
tests/test_litellm/test_cost_calculator.py Adds a focused parameterized regression test that validates both metadata and calculated cached-token cost.

Reviews (1): Last reviewed commit: "fix(pricing): add missing cache_read_inp..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…egression test

Fixes TQ004 and TQ005 violations: raw os.environ assignment and
litellm module-global mutation both outlive the test and leak into
subsequent tests in the same process. monkeypatch restores both at
teardown.
@codspeed

codspeed Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing AbhAy120204:litellm_fix_azure_gpt4o_cache_read (d80663a) with litellm_internal_staging (ff02d5c)

Open in CodSpeed

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Superseded by #37902, the single rolling model-registry PR. Your change was re-verified against the official provider source and rolled in field by field there (see the 2026-08-22 audit run section of that description). Closing this to keep one open registry PR at a time. Thanks for the fix.

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/us/ and azure/eu/ gpt-4o-2024-11-20 missing cache_read_input_token_cost at present cache reads billed at zero

2 participants