Skip to content

feat(anthropic): add Claude Opus 5 - #34518

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_add_claude_opus_5
Jul 24, 2026
Merged

feat(anthropic): add Claude Opus 5#34518
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_add_claude_opus_5

Conversation

@mateo-berri

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • claude-opus-5 is unknown to LiteLLM
  • Requests bill $0, silently
  • Limits report as null instead of 1M/128K
  • No Bedrock, Vertex, or Azure entries

How it solves it:

  • Adds cost map entries for all 10 variants
  • Prices $5/$25 per MTok, 1.1x regional
  • Flags adaptive thinking, 512-token cache minimum
  • Registers Bedrock Converse plus setup wizard

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
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • 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

Live proxy, real Anthropic and Bedrock calls, same config both runs:

model_list:
  - model_name: claude-opus-5
    litellm_params:
      model: anthropic/claude-opus-5
      api_key: os.environ/ANTHROPIC_API_KEY
  - model_name: bedrock-opus-5
    litellm_params:
      model: bedrock/converse/us.anthropic.claude-opus-5
      aws_region_name: us-west-2
      api_key: os.environ/AWS_BEARER_TOKEN_BEDROCK

Before (commit 33b9524daf, port 41733)

The generalization patterns already route the model, so calls succeed; they just cost nothing and carry no limits

$ curl -sS -D - -o /dev/null -X POST http://localhost:41733/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d '{"model":"claude-opus-5","messages":[{"role":"user","content":"What is the capital of France? One word."}],"max_tokens":1024}' \
  | grep -iE '^HTTP/|^x-litellm-response-cost:'
HTTP/1.1 200 OK

$ curl -sS -D - -o /dev/null -X POST http://localhost:41733/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d '{"model":"bedrock-opus-5","messages":[{"role":"user","content":"Reply with exactly: hello"}],"max_tokens":64}' \
  | grep -iE '^HTTP/|^x-litellm-response-cost:'
HTTP/1.1 200 OK

No x-litellm-response-cost header on either route, and /model_group/info has nothing to report:

[
  {
    "model_group": "claude-opus-5",
    "max_input_tokens": null,
    "max_output_tokens": null,
    "input_cost_per_token": 0.0,
    "output_cost_per_token": 0.0
  },
  {
    "model_group": "bedrock-opus-5",
    "max_input_tokens": null,
    "max_output_tokens": null,
    "input_cost_per_token": 0.0,
    "output_cost_per_token": 0.0
  }
]

After (commit ae81625ee6, port 39147)

$ curl -sS -D - -X POST http://localhost:39147/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d '{"model":"claude-opus-5","messages":[{"role":"user","content":"What is the capital of France? One word."}],"max_tokens":1024}'
HTTP/1.1 200 OK
x-litellm-response-cost: 0.00021
content: Paris
usage: 17 in / 5 out

17 x $5/MTok + 5 x $25/MTok = $0.00021, exactly what the header reports

$ curl -sS -D - -X POST http://localhost:39147/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d '{"model":"bedrock-opus-5","messages":[{"role":"user","content":"Reply with exactly: opus 5 online"}],"max_tokens":64}'
HTTP/1.1 200 OK
x-litellm-response-cost: 0.000341
{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"opus 5 online","role":"assistant"}}],
 "usage":{"completion_tokens":8,"prompt_tokens":22,"total_tokens":30}}

22 x $5.50/MTok + 8 x $27.50/MTok = $0.000341, i.e. the 1.1x cross-region premium is applied

$ curl -sS -D - -X POST http://localhost:39147/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H 'Content-Type: application/json' \
    -d '{"model":"claude-opus-5","reasoning_effort":"xhigh","messages":[{"role":"user","content":"What is 17*23? Answer with the number only."}],"max_tokens":2048}'
HTTP/1.1 200 OK
x-litellm-response-cost: 0.000755
{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"391","role":"assistant",
 "thinking_blocks":[{"type":"thinking","signature":"CAISpQIKhwEIEBgCKkC+6Vc1kva..."}]}}],
 "usage":{"completion_tokens":26,"prompt_tokens":21,"total_tokens":47}}
$ curl -sS http://localhost:39147/model_group/info -H "Authorization: Bearer $LITELLM_MASTER_KEY"
[
  {
    "model_group": "claude-opus-5",
    "max_input_tokens": 1000000.0,
    "max_output_tokens": 128000.0,
    "input_cost_per_token": 5e-06,
    "output_cost_per_token": 2.5e-05,
    "supports_reasoning": true,
    "supports_vision": true,
    "supports_function_calling": true
  },
  {
    "model_group": "bedrock-opus-5",
    "max_input_tokens": 1000000.0,
    "max_output_tokens": 128000.0,
    "input_cost_per_token": 5.5e-06,
    "output_cost_per_token": 2.75e-05,
    "supports_reasoning": true,
    "supports_vision": true,
    "supports_function_calling": true
  }
]

The Vertex AI and Azure AI entries could not be exercised live from this machine (expired ADC credentials and a 401 from the local Foundry endpoint respectively), so they are copied from the corresponding Opus 4.8 entries with the same three deltas as every other variant

Type

🆕 New Feature

Changes

Ten cost-map entries land in both model_prices_and_context_window.json and the bundled litellm/model_prices_and_context_window_backup.json: the first-party claude-opus-5, the Bedrock profiles (anthropic., global.anthropic., us., eu., au., jp.), vertex_ai/claude-opus-5 plus its @default alias, and azure_ai/claude-opus-5. Each is derived from its Opus 4.8 sibling, so pricing stays at $5/$25 per MTok with the usual 1.25x cache write, 2x 1-hour cache write, and 0.1x cache read multipliers, the regional Bedrock profiles keep the 1.1x premium, and the gen-5 capability profile (adaptive thinking, no sampling params, no assistant prefill, xhigh and max effort) carries over

Three fields differ from Opus 4.8. prompt_cache_min_tokens drops from 1024 to 512, which is what the router's prompt-caching check reads. bedrock_output_config_effort_ceiling is dropped entirely because Bedrock accepts output_config.effort="max" for Opus 5; verified with a live 200 against us.anthropic.claude-opus-5. And azure_ai/claude-opus-5 gets the full max_input_tokens: 1000000 rather than the 200000 the Azure Opus 4.8 entry carries

Outside the cost maps, anthropic.claude-opus-5 joins BEDROCK_CONVERSE_MODELS, the setup wizard lists the model under Anthropic, and the live reasoning-effort grid gains a claude-opus-5 entry so the effort ladder is exercised against the real API

tests/test_litellm/test_claude_opus_5_config.py covers pricing and capabilities, regional Bedrock pricing, the absent effort ceiling, strict-tool rejection on Converse, the 512-token cache minimum, fast-mode pricing at 2x, backup-map parity, and provider resolution. Every assertion was mutation-checked: reverting any of the three deltas, the pricing, or the limits fails at least one test

One note for a follow-up, out of scope here: _BEDROCK_OUTPUT_CONFIG_EFFORT_ORDER in litellm/llms/bedrock/common_utils.py ranks max (3) below xhigh (4), so the xhigh ceiling on Opus 4.7 and 4.8 never actually clamps a max request. That inversion is why the ceiling test here asserts the cost-map entry rather than calling the normalizer

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

Registers claude-opus-5 across the cost maps and provider lists so the model
prices, reports its real 1M/128K limits, and advertises its capabilities instead
of falling through the generalization patterns at zero cost.

Adds the first-party entry plus the Bedrock (base, global, us, eu, au, jp),
Vertex AI, and Azure AI variants. Pricing matches Opus 4.8 at $5/$25 per MTok
with the usual 1.1x regional premium on the cross-region inference profiles, and
fast mode is priced at 2x through provider_specific_entry on the first-party
entry only.

Two fields deliberately differ from Opus 4.8: prompt_cache_min_tokens drops to
512, and bedrock_output_config_effort_ceiling is omitted because Bedrock accepts
output_config.effort="max" for Opus 5.
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Claude Opus 5 support across LiteLLM's provider and model metadata surfaces

  • Registers pricing, context limits, caching thresholds, and capabilities for Anthropic, Bedrock, Vertex AI, and Azure AI variants
  • Registers the Bedrock Converse model and adds Opus 5 to the Anthropic setup wizard
  • Extends reasoning-effort coverage and adds focused configuration, pricing, fallback-map, and provider-resolution tests

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified

The new model identifiers resolve through their intended providers, Bedrock variants route through Converse, root and fallback metadata agree, and the added tests exercise the behavior-bearing pricing and capability fields without network access

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds consistent Claude Opus 5 pricing and capability metadata for ten direct and hosted-provider variants
litellm/model_prices_and_context_window_backup.json Mirrors the new Opus 5 entries in the bundled fallback cost map
litellm/constants.py Registers the base Bedrock Opus 5 identifier for Converse routing
litellm/setup_wizard.py Adds Claude Opus 5 to the Anthropic models generated by the setup wizard
tests/llm_translation/reasoning_effort_grid/grid_spec.py Adds the direct Anthropic Opus 5 model to live reasoning-effort coverage
tests/test_litellm/test_claude_opus_5_config.py Adds local-only tests for pricing, capabilities, provider resolution, fallback metadata, caching, strict tools, and fast mode

Reviews (1): Last reviewed commit: "feat(anthropic): add Claude Opus 5" | Re-trigger Greptile

@mateo-berri
mateo-berri enabled auto-merge July 24, 2026 17:51
"supports_vision": true,
"supports_xhigh_reasoning_effort": true,
"supports_max_reasoning_effort": true,
"provider_specific_entry": {

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.

High: Prompt-cache usage bypasses pricing modifiers

The new us and fast modifiers are applied in litellm/llms/anthropic/cost_calculation.py only after cache read/write costs are subtracted. An authenticated user can issue cache-heavy Opus 5 requests with inference_geo="us" or speed="fast" and have those cached tokens charged at the base rate instead of the selected provider rate, allowing their proxy budget to understate upstream spend. Apply provider-specific modifiers to the applicable cache charges as well, and cover cached usage in the pricing test and bundled backup entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a billing thing and it's not related to Opus 5. We will cut a new PR for this

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@BerriAI BerriAI deleted a comment from veria-ai Bot Jul 24, 2026
@mateo-berri
mateo-berri merged commit e7df795 into litellm_internal_staging Jul 24, 2026
76 of 77 checks passed
@mateo-berri
mateo-berri deleted the litellm_add_claude_opus_5 branch July 24, 2026 17:59
@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_add_claude_opus_5 (ae81625) with litellm_internal_staging (64aad58)1

Open in CodSpeed

Footnotes

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

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