Skip to content

feat(anthropic): add Claude Sonnet 5 - #31740

Merged
yuneng-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_add-claude-sonnet-5-c71c
Jun 30, 2026
Merged

yuneng-berri merged 3 commits into
litellm_internal_stagingfrom
litellm_add-claude-sonnet-5-c71c

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Relevant issues

Adds support for Claude Sonnet 5 (claude-sonnet-5), released by Anthropic on June 30, 2026

Linear ticket

N/A

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 requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Changes

Registers claude-sonnet-5 across the cost map so it resolves on every surface it ships on. The new entries cover Anthropic direct (claude-sonnet-5), Bedrock (anthropic.claude-sonnet-5 plus the global/us/eu/au/jp cross-region inference profiles), Vertex AI (vertex_ai/claude-sonnet-5 and vertex_ai/claude-sonnet-5@default), and Azure AI / Microsoft Foundry (azure_ai/claude-sonnet-5). The entries land in both model_prices_and_context_window.json and the bundled litellm/model_prices_and_context_window_backup.json so the model resolves whether litellm uses the network-fetched map or the local fallback. anthropic.claude-sonnet-5 is added to BEDROCK_CONVERSE_MODELS and claude-sonnet-5 to the setup-wizard provider list

Sonnet 5 uses the gen-5 adaptive-thinking profile (adaptive thinking always on, no extended thinking, effort defaults to high), so the entries follow Fable 5 / Opus 4.8 rather than the older Sonnet 4.6 shape: supports_sampling_params and supports_assistant_prefill are false (the API rejects temperature other than 1, top_p, top_k, and prefill on this generation, verified live below), while supports_adaptive_thinking, supports_xhigh_reasoning_effort, and supports_max_reasoning_effort are true. Pricing uses standard Sonnet rates of $3 / $15 per MTok with the usual 1.25x cache-write and 0.1x cache-read multipliers; the us/eu/au/jp Bedrock profiles carry the standard 10% regional premium ($3.30 / $16.50 per MTok). Context window is 1M input / 128k output. Anthropic's introductory $2 / $10 pricing through August 31, 2026 is intentionally not encoded since it is a temporary discount

A reasoning-effort grid entry is added for the Anthropic direct route, and a new regression test (tests/test_litellm/test_claude_sonnet_5_config.py) pins pricing, the gen-5 capability flags, the regional premiums, root/backup parity, Bedrock-converse registration, and bare-name provider resolution

Screenshots / Proof of Fix

Real end-to-end call against the live Anthropic API (no mocks, real tokens billed):

$ python -c "import litellm; r=litellm.completion(model='claude-sonnet-5', messages=[{'role':'user','content':'In 5 words, what model are you?'}], max_tokens=40); print(r.choices[0].message.content); print(r.model, r.usage.total_tokens); print('cost USD:', litellm.completion_cost(completion_response=r))"
I'm Claude, made by Anthropic.
claude-sonnet-5 34
cost USD: 0.000306

The gen-5 capability flags are verified directly against the Anthropic Messages API, confirming the entries match real provider behavior:

temperature=1:       HTTP 200
temperature=0.5:     HTTP 400  `temperature` is deprecated for this model.
top_p=0.9:           HTTP 400  `top_p` is deprecated for this model.
top_k=10:            HTTP 400  `top_k` is deprecated for this model.
assistant prefill:   HTTP 400  This model does not support assistant message prefill. The conversation must end with a user message.

That matches supports_sampling_params: false and supports_assistant_prefill: false on every Sonnet 5 entry

Multi-provider e2e QA (real calls, no mocks)

Bedrock is fully verified end to end against us-east-1 through the US cross-region inference profile, on both the Converse and the InvokeModel routes, with a real billed 200 and the cost computed from the new map entry:

bedrock/us.anthropic.claude-sonnet-5         -> "Sonnet 5 online"  (Converse,     usage 23+11, cost $0.000257)
bedrock/invoke/us.anthropic.claude-sonnet-5  -> "Sonnet 5 online"  (InvokeModel,  usage 23+11, cost $0.000234)

The bare on-demand id is registered too, and Bedrock itself rejects on-demand throughput for this generation and asks for an inference profile, which is the expected provider behavior rather than a routing bug:

bedrock/anthropic.claude-sonnet-5 -> HTTP 400  Invocation of model ID anthropic.claude-sonnet-5 with on-demand
                                                throughput isn't supported. Retry your request with the ID or ARN
                                                of an inference profile that contains this model.

Vertex AI and Azure AI Foundry were exercised against the live APIs as well, and litellm builds and sends the correct request on both: Vertex rawPredict/streamRawPredict to publishers/anthropic/models/claude-sonnet-5 (the @default alias is preserved), and Azure POST /anthropic/v1/messages with the anthropic-version header and the transformed body. Both providers accept and route the request, so litellm's transformation and pricing are confirmed end to end. We could not obtain a full 200 on either because neither test account has been granted Sonnet 5 token throughput yet, which is external to litellm and expected for a same-day release: on Vertex the model is enabled in Model Garden but its per-base-model online-prediction token quota in us-east5 defaults to 0, so calls return 429 RESOURCE_EXHAUSTED (a quota-increase request has been filed and is pending), and on Azure the model is offered and deployable in eastus2 but its AIServices.GlobalStandard.claude-sonnet-5 capacity quota is 0/0, so a deployment cannot be created until that quota is raised. In both cases the model is recognized by the provider and the sole gate is a zero default quota on a brand-new model, not anything in this PR

Proxy reproduction for reviewers on a funded key

python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml --detailed_debug --reload --use_v2_migration_resolver 2>&1 | tee litellm.log
curl -s http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-1234" \
  -d '{"model": "claude-sonnet-5", "messages": [{"role": "user", "content": "Reply with exactly: Sonnet 5 online"}], "max_tokens": 20}'

Type

🆕 New Feature

Slack Thread

Open in Web Open in Cursor 

Register claude-sonnet-5 across the Anthropic, Bedrock (base + global/us/eu/au/jp
cross-region inference profiles), Vertex AI, and Azure AI cost-map entries in both
the root and bundled-backup model maps, plus BEDROCK_CONVERSE_MODELS and the
setup-wizard provider list.

Sonnet 5 ships with the gen-5 adaptive-thinking profile (adaptive thinking always
on, no extended thinking, effort defaults to high), so the entries mirror the
Fable 5 / Opus 4.8 sampling-param and prefill restrictions rather than the older
Sonnet 4.6 behavior: supports_sampling_params and supports_assistant_prefill are
false while supports_adaptive_thinking, supports_xhigh_reasoning_effort, and
supports_max_reasoning_effort are true. Pricing follows standard Sonnet rates
($3 / $15 per MTok) with the 10% regional premium on the us/eu/au/jp profiles.

Add a reasoning-effort grid entry for the Anthropic direct route and a regression
test pinning pricing, capabilities, regional premiums, backup parity, and bare-name
provider resolution.

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
@CLAassistant

CLAassistant commented Jun 30, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ mateo-berri
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

@codspeed

codspeed Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 27 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_completion_multi_turn 3.1 ms 4.2 ms -25.36%
⚡ test_completion_with_tools 4.2 ms 3.2 ms +30.76%
⚡ test_completion_simple_message 4.2 ms 3.2 ms +28.82%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing litellm_add-claude-sonnet-5-c71c (6d43c21) with litellm_internal_staging (6d828e5)

Open in CodSpeed

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri
mateo-berri marked this pull request as ready for review June 30, 2026 18:59
…net-5

The Sonnet 5 grid entry raised the Anthropic direct route to 30 model
combos, so test_grid_cell_count now expects 330 cells instead of 319.
@mateo-berri

mateo-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR registers claude-sonnet-5 across LiteLLM's cost map for all supported surfaces: Anthropic direct, Bedrock (base + global/us/eu/au/jp cross-region profiles), Vertex AI, and Azure AI. It follows the established gen-5 adaptive-thinking profile pattern set by claude-fable-5 and claude-opus-4-8.

  • Capability flags (supports_sampling_params: false, supports_assistant_prefill: false, supports_adaptive_thinking: true, supports_output_config: true) are consistent with the gen-5 model family and verified against the live API in the PR description.
  • Pricing is correct at $3/$15 per MTok with a 10% regional premium for us/eu/au/jp Bedrock profiles; all math checks out against existing entries.
  • The regression test suite (test_claude_sonnet_5_config.py) uses only local JSON reads and monkeypatching — no real network calls — in compliance with the no-live-calls rule for tests/test_litellm/.

Confidence Score: 5/5

Safe to merge — all changes are additive cost-map and constant registrations with no modifications to existing entries or runtime logic.

Every new entry follows the established gen-5 model pattern (claude-fable-5 / claude-opus-4-8) exactly: capability flags, pricing math, regional premium calculations, and the presence/absence of provider-specific fields on each surface all check out. The backup JSON mirrors the root map, tests are purely local with no network calls, and the new test suite provides solid regression coverage for pricing, capability flags, and provider resolution.

No files require special attention.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds ten claude-sonnet-5 entries (Anthropic, Bedrock x6, Vertex AI x2, Azure AI) with correct gen-5 capability flags and pricing; follows the claude-fable-5 pattern precisely.
litellm/model_prices_and_context_window_backup.json Mirrors the same ten entries from the root cost map; parity verified by the new test_sonnet_5_present_in_bundled_backup test.
litellm/constants.py Adds anthropic.claude-sonnet-5 to BEDROCK_CONVERSE_MODELS, correctly positioned adjacent to other gen-5 models.
tests/test_litellm/test_claude_sonnet_5_config.py New test file covering pricing, regional premiums, backup parity, BEDROCK_CONVERSE_MODELS registration, provider resolution, and adaptive-thinking flags — all tests are purely local (JSON reads + monkeypatching, no network calls).
tests/llm_translation/reasoning_effort_grid/grid_spec.py Adds claude-sonnet-5 to ANTHROPIC_DIRECT_MODELS with mode="adaptive" and _CAPS_XHIGH_MAX, consistent with other gen-5 entries.
tests/llm_translation/reasoning_effort_grid/test_reasoning_effort_grid.py Updates grid cell count assertion from 29×11 to 30×11 to account for the new model entry.
litellm/setup_wizard.py Adds claude-sonnet-5 to the Anthropic provider model list in the setup wizard.

Reviews (3): Last reviewed commit: "fix(anthropic): drop redundant supports_..." | Re-trigger Greptile

…re Sonnet 5

The Vertex AI and Azure AI Sonnet 5 entries carried supports_output_config:
true, which the gen-5 siblings (vertex_ai/claude-opus-4-8, azure_ai/claude-fable-5,
etc.) do not. The flag only feeds AnthropicConfig._model_supports_effort_param,
which already returns true for these entries via supports_xhigh/max_reasoning_effort,
so output_config.effort still forwards on both routes. Removing it is behavior
neutral and matches the existing per-platform convention for gen-5 Claude.
@mateo-berri

mateo-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

On the supports_output_config note: I dropped it from vertex_ai/claude-sonnet-5, vertex_ai/claude-sonnet-5@default, and azure_ai/claude-sonnet-5 so they match the existing gen-5 convention on those platforms, where vertex_ai/claude-opus-4-8, azure_ai/claude-fable-5, and the rest of the siblings omit it. The Anthropic-direct and Bedrock entries keep it, matching their own siblings.

Worth being precise about the 400 framing though, since this flag was not what gates output_config.effort forwarding on Vertex or Azure. That path runs through AnthropicConfig._model_supports_effort_param, which is an OR of supports_output_config and any supports_*_reasoning_effort flag. The Sonnet 5 entries still advertise supports_xhigh_reasoning_effort and supports_max_reasoning_effort, so _model_supports_effort_param stays True and effort forwards exactly as before. The gen-5 siblings already forward effort on those same routes via those same reasoning-effort flags, so there was never a new 400 path here; the removal is behavior neutral and purely a consistency cleanup

@mateo-berri

mateo-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

mateo-berri commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

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.

✅ 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 6d43c21. Configure here.

@yuneng-berri
yuneng-berri enabled auto-merge June 30, 2026 20:14
@yuneng-berri
yuneng-berri merged commit 8beb68a into litellm_internal_staging Jun 30, 2026
78 of 79 checks passed
@yuneng-berri
yuneng-berri deleted the litellm_add-claude-sonnet-5-c71c branch June 30, 2026 20:14
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.

4 participants