Skip to content

feat(bedrock_mantle): add Claude Opus 5, Sonnet 5, and Haiku 4.5 support - #34625

Open
bharatlakhiyani wants to merge 3 commits into
BerriAI:mainfrom
bharatlakhiyani:litellm_bedrock_mantle_claude_5_models
Open

bharatlakhiyani wants to merge 3 commits into
BerriAI:mainfrom
bharatlakhiyani:litellm_bedrock_mantle_claude_5_models

Conversation

@bharatlakhiyani

@bharatlakhiyani bharatlakhiyani commented Jul 25, 2026 •

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Mantle serves Claude under dateless IDs; Haiku 4.5 had no dateless cost-map entry, so spend tracked as $0
  • get_model_info on bedrock/mantle/... resolved generic fallback limits, not the real 1M/128K entries

How it solves it:

  • Adds the anthropic.claude-haiku-4-5 entry to both cost-map JSONs
  • Strips the mantle/ routing prefix in strip_bedrock_routing_prefix so exact entries resolve

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

Reproduction before the fix, at base commit 7b019cf (checked out in a separate worktree, local cost map):

BEFORE opus-5 via mantle: 200000 max_input / 0 input cost
BEFORE haiku-4-5 cost for 1k in + 1k out: 0.0

After the fix, at b256753, same script:

AFTER opus-5 via mantle: 1000000 max_input / 5e-06 input cost
AFTER haiku-4-5 cost for 1k in + 1k out: 0.006

Live proxy proof at b256753, hitting the real bedrock-mantle.us-east-1.api.aws endpoint (SigV4, real $). Proxy started with a config containing three deployments (claude-opus-5-mantle, claude-sonnet-5-mantle, claude-haiku-4-5-mantle mapping to bedrock/mantle/anthropic.claude-{opus-5,sonnet-5,haiku-4-5}), then:

for m in claude-opus-5-mantle claude-sonnet-5-mantle claude-haiku-4-5-mantle; do
  curl -s -D - -o /dev/null http://localhost:4000/v1/chat/completions \
    -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
    -d "{\"model\": \"$m\", \"messages\": [{\"role\": \"user\", \"content\": \"What is 2+2? Digits only.\"}], \"max_tokens\": 512}" \
    | grep -i x-litellm-response-cost:
done
=== claude-opus-5-mantle ===
x-litellm-response-cost: 0.00017500000000000003
=== claude-sonnet-5-mantle ===
x-litellm-response-cost: 8.6e-05
=== claude-haiku-4-5-mantle ===
x-litellm-response-cost: 4.3e-05

All three answered "4" and the costs match the per-token rates exactly (e.g. haiku: 23 in x 1e-06 + 4 out x 5e-06 = 4.3e-05; before this PR the haiku header read 0.0)

The native /v1/messages surface works on the same deployments, non-streaming and streaming:

curl -s http://localhost:4000/v1/messages \
  -H "Authorization: Bearer sk-1234" -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-4-5-mantle", "messages": [{"role": "user", "content": "What is 2+2? Answer with just the number."}], "max_tokens": 64}'
{"model": "claude-haiku-4-5-mantle", "content": [{"type": "text", "text": "4"}], "usage": {"input_tokens": 20, "output_tokens": 5, ...}}

Streaming (claude-sonnet-5-mantle, "stream": true) returned the raw Anthropic SSE pass-through starting with event: message_start and "model":"claude-sonnet-5" from the wire

Type

🆕 New Feature

Changes

The Mantle endpoint (bedrock-mantle.{region}.api.aws/anthropic/v1/messages) serves Claude models under dateless IDs per the AWS model cards: anthropic.claude-opus-5, anthropic.claude-sonnet-5, and anthropic.claude-haiku-4-5. The bedrock/mantle/ route itself is model-agnostic, but two data/resolution gaps kept these models from working correctly

First, anthropic.claude-haiku-4-5 had no cost-map entry; only the dated bedrock-runtime ID anthropic.claude-haiku-4-5-20251001-v1:0 exists. Since the Mantle wire response reports the dateless ID, Haiku responses were cost-tracked at $0. This PR adds the dateless entry (200K in / 64K out, $1/$5 per 1M tokens, cache write $1.25 / read $0.10, 1h TTL pricing, prompt_cache_min_tokens 4096) to model_prices_and_context_window.json and litellm/model_prices_and_context_window_backup.json. It uses litellm_provider "bedrock", matching the anthropic.claude-mythos-preview Mantle precedent, and deliberately stays out of BEDROCK_CONVERSE_MODELS because the dateless ID does not exist on bedrock-runtime Converse

Second, strip_bedrock_routing_prefix did not strip the mantle/ routing prefix, so get_model_info("bedrock/mantle/anthropic.claude-opus-5") fell through to generalization fallbacks: generic 200K/64K limits, zero cache pricing, and no output_config capability flags, instead of the exact 1M/128K bare-model entries. Adding "mantle/" to the prefix list fixes resolution for all mantle-routed models (it also makes is_claude_4_5_on_bedrock detect 1h cache TTL support correctly for them). Route detection is unaffected: explicit route prefixes are matched before base-model resolution, and the bedrock_mantle/ provider prefix is still left intact by segment-boundary matching, covered by a regression test

Tests added in tests/test_litellm/llms/bedrock/test_mantle.py: exact model-info resolution for all three models (limits and per-token costs, so a deleted JSON entry or a reverted prefix fix both fail), mantle route detection for the new IDs, prefix-strip behavior including the bedrock_mantle/ non-collision, and Haiku cost tracking through completion_cost. The local_cost_map fixture clears all model-cost LRU caches via _invalidate_model_cost_lowercase_map so the cost test cannot become order-dependent

Why the diff looks smaller for Opus 5 and Sonnet 5: their dateless entries (anthropic.claude-opus-5, anthropic.claude-sonnet-5) already exist upstream from the general Bedrock launch commits, so those two only needed the prefix-strip fix to resolve correctly through the mantle route. Haiku 4.5 is the only one whose dateless ID was missing from the cost map. All three ride the same bedrock/mantle/ route and the same fix; the tests are parametrized over all three model IDs

Note for CI: the OSV scan currently fails on the base branch itself (gitpython 3.1.52 in uv.lock plus postcss/brace-expansion in the dashboard lockfile). This PR cannot carry the fix because fork PRs must not modify uv.lock; the bumps need a branch in the canonical repository (gitpython to 3.1.55 needs an exclude-newer-package override in pyproject.toml since the release is inside the 3-day exclude-newer window; postcss to 8.5.18 and brace-expansion to 5.0.8 in the dashboard pins and overrides). Verified locally that those bumps make osv-scanner v2.3.8 report "No issues found" with the exact workflow invocation

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

The Mantle endpoint serves Claude models under dateless IDs
(anthropic.claude-opus-5, anthropic.claude-sonnet-5,
anthropic.claude-haiku-4-5 per the AWS model cards). Two gaps prevented
correct handling:

1. anthropic.claude-haiku-4-5 had no cost-map entry (only the dated
bedrock-runtime ID anthropic.claude-haiku-4-5-20251001-v1:0 exists), so
Mantle Haiku responses were cost-tracked at $0. Add the dateless entry
(200K in / 64K out, $1/$5 per 1M tokens, prompt caching).

2. strip_bedrock_routing_prefix did not strip the mantle/ routing
prefix, so get_model_info on bedrock/mantle/anthropic.claude-* resolved
generalization fallbacks (generic 200K/64K limits, no cache pricing, no
output_config capability flags) instead of the exact bare-model entries.
Add mantle/ to the prefix list; route detection is unaffected because
explicit route prefixes are matched before base-model resolution, and
the bedrock_mantle/ provider prefix is still left intact (segment-
boundary matching).
get_model_info.cache_clear() alone leaves _cached_get_model_info_helper
(used by completion_cost) holding entries from whichever cost map was
active first, making the cost-tracking test order-dependent. Use
_invalidate_model_cost_lowercase_map, which clears both caches and the
lowercase lookup map.
@CLAassistant

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 sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds accurate Bedrock Mantle metadata and model resolution for dateless Claude model IDs.

  • Adds the dateless Claude Haiku 4.5 pricing, context-window, caching, and capability metadata to both cost maps.
  • Normalizes the mantle/ routing prefix so Mantle models resolve their exact cost-map entries.
  • Adds regression coverage for route detection, prefix normalization, model information, and Haiku cost tracking.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
litellm/llms/bedrock/common_utils.py Adds mantle/ to iterative Bedrock routing-prefix normalization while preserving the distinct bedrock_mantle/ provider prefix.
model_prices_and_context_window.json Adds the dateless Claude Haiku 4.5 Bedrock metadata required for Mantle model information and cost calculation.
litellm/model_prices_and_context_window_backup.json Mirrors the new dateless Claude Haiku 4.5 metadata in the packaged local cost map.
tests/test_litellm/llms/bedrock/test_mantle.py Adds isolated regression tests covering exact model resolution, Mantle routing, prefix handling, and completion cost.

Reviews (2): Last reviewed commit: "test(bedrock): clear all model-cost LRU ..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@bharatlakhiyani

Copy link
Copy Markdown
Author

The failing OSV scan is unrelated to this change; it flags gitpython 3.1.52 in uv.lock and postcss/brace-expansion in the dashboard lockfile, none of which this PR touches, and it fails the same way on the base branch. Opened #34626 with the dependency bumps; once that merges I'll rebase this branch to rerun the scan

@codspeed

codspeed Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing bharatlakhiyani:litellm_bedrock_mantle_claude_5_models (740bc96) with litellm_internal_staging (4eecf7a)

Open in CodSpeed

@bharatlakhiyani

Copy link
Copy Markdown
Author

Dropped the dependency-bump commit from this branch: the lockfile-guard check rejects any fork PR that modifies uv.lock, so the OSV fix has to come from a branch in the canonical repository. For a maintainer picking it up: bump gitpython to 3.1.55 (needs a [tool.uv.exclude-newer-package] gitpython override in pyproject.toml since the release is inside the 3-day exclude-newer window; lock regenerated with uv 0.10.9), and in ui/litellm-dashboard bump postcss to 8.5.18 and brace-expansion to 5.0.8 in both the devDependency pins and the overrides block. Verified locally that with those bumps osv-scanner v2.3.8 reports "No issues found" using the exact invocation from .github/workflows/osv-scan.yml. Until that lands on litellm_internal_staging, the OSV failure on this PR is pre-existing on the base branch and unrelated to this change

@bharatlakhiyani

Copy link
Copy Markdown
Author

@greptileai

@bharatlakhiyani

Copy link
Copy Markdown
Author

@ryan-crabbe-berri this is ready for your review can you please help?

This branch has not been deployed

No deployments
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.

3 participants