Skip to content

fix: add 1h cache pricing for vertex claude sonnet 4.6 - #26409

Closed
biubiubiuboomboomboom wants to merge 3 commits into
BerriAI:litellm_oss_branchfrom
biubiubiuboomboomboom:codex/fix-vertex-ai-claude-sonnet-4-6-cache-pricing
Closed

fix: add 1h cache pricing for vertex claude sonnet 4.6#26409
biubiubiuboomboomboom wants to merge 3 commits into
BerriAI:litellm_oss_branchfrom
biubiubiuboomboomboom:codex/fix-vertex-ai-claude-sonnet-4-6-cache-pricing

Conversation

@biubiubiuboomboomboom

Copy link
Copy Markdown

Summary

  • add cache_creation_input_token_cost_above_1hr for vertex_ai/claude-sonnet-4-6
  • add the same 1h cache write rate for vertex_ai/claude-sonnet-4-6@default
  • add a regression test covering Vertex Claude Sonnet 4.6 1h cache write pricing through generic_cost_per_token

Validation

  • verified locally with LITELLM_LOCAL_MODEL_COST_MAP=True that generic_cost_per_token(..., custom_llm_provider="vertex_ai") returns (6.0, 0.0) for ephemeral_1h_input_tokens=1_000_000
  • added a regression test for the same scenario

@CLAassistant

CLAassistant commented Apr 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@veria-ai

veria-ai Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Low: No security issues found

This PR adds a cache_creation_input_token_cost_above_1hr pricing field for two Vertex AI Claude Sonnet 4.6 model entries in the pricing JSON files, along with corresponding tests. The remaining changes in factory.py are purely formatting (black/ruff auto-reformatting) with no logic changes. No security-relevant code paths are affected.


Status: 0 open
Risk: 1/10

Posted by Veria AI · 2026-04-24T10:40:59.348Z

@greptile-apps

greptile-apps Bot commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds cache_creation_input_token_cost_above_1hr: 6e-06 for vertex_ai/claude-sonnet-4-6 and vertex_ai/claude-sonnet-4-6@default to both the root model_prices_and_context_window.json and the bundled backup. The factory.py changes are purely Black-formatter reformatting with no logic changes, and two complementary regression tests are included — one verifying the cost calculation via the backup map and one asserting the field exists in the root JSON directly.

Confidence Score: 5/5

This PR is safe to merge — it adds a missing pricing field to both the production and backup JSON files, with two complementary regression tests covering both paths.

Both JSON files (root production and bundled backup) are correctly updated. The previous gap where the root file was missing the field has been addressed in this version of the PR. The new test in test_claude_opus_4_6_config.py directly asserts the root JSON contains the field, closing the test coverage gap from prior review. The factory.py diff is purely cosmetic reformatting with no logic impact. No P0 or P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds cache_creation_input_token_cost_above_1hr: 6e-06 for both vertex_ai/claude-sonnet-4-6 and vertex_ai/claude-sonnet-4-6@default — addresses previous concern about the root production file being missing the field.
litellm/model_prices_and_context_window_backup.json Adds the same cache_creation_input_token_cost_above_1hr: 6e-06 entries to the bundled backup JSON for both vertex_ai model variants.
tests/test_litellm/test_claude_opus_4_6_config.py New test test_vertex_ai_claude_sonnet_4_6_has_1h_cache_write_pricing_in_root_map directly reads the root JSON file to confirm both vertex_ai entries contain the correct 1h cache pricing field.
litellm/litellm_core_utils/prompt_templates/factory.py Pure Black formatter reformatting of multi-line expressions — no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[generic_cost_per_token\ncustom_llm_provider=vertex_ai\nmodel=claude-sonnet-4-6] --> B{Load model info}
    B -->|LITELLM_LOCAL_MODEL_COST_MAP=True| C[model_prices_and_context_window_backup.json]
    B -->|Production remote fetch| D[model_prices_and_context_window.json]
    C --> E[cache_creation_input_token_cost_above_1hr: 6e-06]
    D --> E
    E --> F{Token type?}
    F -->|ephemeral_5m_input_tokens| G[cost x 3.75e-06]
    F -->|ephemeral_1h_input_tokens| H[cost x 6e-06]
    H --> I[prompt_cost = 6.0 for 1M tokens]
Loading

Reviews (4): Last reviewed commit: "style: format prompt template factory" | Re-trigger Greptile

@biubiubiuboomboomboom
biubiubiuboomboomboom force-pushed the codex/fix-vertex-ai-claude-sonnet-4-6-cache-pricing branch from e14b226 to 45f3857 Compare April 24, 2026 10:25
@codecov

codecov Bot commented Apr 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.85714% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...llm/litellm_core_utils/prompt_templates/factory.py 42.85% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

2 participants