Skip to content

feat(bedrock): add support for bedrock-mantle endpoint (Claude Mythos Preview) - #26196

Merged
8 commits merged into
litellm_internal_stagingfrom
litellm_bedrock_mantle_ant
Apr 21, 2026
Merged

8 commits merged into
litellm_internal_stagingfrom
litellm_bedrock_mantle_ant

Conversation

@ghost

@ghost ghost commented Apr 21, 2026

Copy link
Copy Markdown

Relevant issues

Adds support for the new AWS Bedrock bedrock-mantle endpoint, which serves Claude Mythos Preview (anthropic.claude-mythos-preview) using the Anthropic Messages API format.

Changes

Usage:

# /chat/completions
response = litellm.completion(
    model="bedrock/mantle/anthropic.claude-mythos-preview",
    messages=[{"role": "user", "content": "Hello"}],
    aws_region_name="us-east-1",
)

# /messages
response = await litellm.anthropic_messages(
    model="bedrock/mantle/anthropic.claude-mythos-preview",
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=1024,
    aws_region_name="us-east-1",
)

The bedrock-mantle endpoint differs from standard Bedrock in two ways:

  • Different endpoint: https://bedrock-mantle.{region}.api.aws/v1/messages
  • Uses Anthropic Messages API format (not Bedrock Invoke/Converse), so model goes in the request body rather than the URL

Route pattern: bedrock/mantle/<model-id> — consistent with existing explicit routes (bedrock/converse/..., bedrock/agentcore/...).

Auth: AWS SigV4 with service=bedrock, same as other Bedrock models.

Files:

  • model_prices_and_context_window.json — adds anthropic.claude-mythos-preview (1M context, 128K output, supports reasoning + vision; pricing TBD)
  • litellm/llms/bedrock/common_utils.py — adds "mantle" route, _explicit_mantle_route() helper, dispatch in get_bedrock_chat_config() and get_bedrock_provider_config_for_messages_api()
  • litellm/llms/bedrock/chat/mantle/transformation.py — AmazonMantleConfig for /chat/completions
  • litellm/llms/bedrock/messages/mantle_transformation.py — AmazonMantleMessagesConfig for /messages (inherits AmazonAnthropicClaudeMessagesConfig)
  • litellm/__init__.py + litellm/_lazy_imports_registry.py — registration

QA results (fake mantle endpoint)

Intercepted outgoing HTTP calls to verify full request/response pipeline for both endpoints.

/chat/completions

Request:

POST https://bedrock-mantle.us-east-1.api.aws/v1/messages
Authorization: AWS4-HMAC-SHA256 Credential=.../us-east-1/bedrock/aws4_request ...

{
  "messages": [{"role": "user", "content": [{"type": "text", "text": "Hello!"}]}],
  "max_tokens": 100,
  "anthropic_version": "bedrock-2023-05-31",
  "model": "anthropic.claude-mythos-preview"
}

Response (OpenAI format):

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "anthropic.claude-mythos-preview",
  "choices": [{
    "finish_reason": "stop",
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! I am Claude Mythos Preview running via bedrock-mantle."
    }
  }],
  "usage": {"prompt_tokens": 12, "completion_tokens": 15, "total_tokens": 27}
}

/messages

Request:

POST https://bedrock-mantle.us-east-1.api.aws/v1/messages
Authorization: AWS4-HMAC-SHA256 Credential=.../us-east-1/bedrock/aws4_request ...

{
  "messages": [{"role": "user", "content": "Hello!"}],
  "max_tokens": 100,
  "anthropic_version": "bedrock-2023-05-31",
  "model": "anthropic.claude-mythos-preview"
}

Response (Anthropic format):

{
  "id": "msg_fake456",
  "type": "message",
  "role": "assistant",
  "model": "anthropic.claude-mythos-preview",
  "content": [{"type": "text", "text": "Hello! I am Claude Mythos Preview running via bedrock-mantle."}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 12, "output_tokens": 15, "total_tokens": 27}
}

Test results (12/12 passed):

tests/test_litellm/llms/bedrock/test_mantle.py::test_explicit_mantle_route_flag PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_get_bedrock_chat_config_returns_mantle_config PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_get_bedrock_provider_config_for_messages_api_mantle PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_get_bedrock_route_mantle PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_get_bedrock_route_mantle_does_not_match_other_routes PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_mantle_messages_url_construction PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_mantle_transform_request_strips_prefix_and_adds_model PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_mantle_url_construction PASSED
tests/test_litellm/llms/bedrock/test_mantle.py::test_mantle_url_construction_different_region PASSED
tests/llm_translation/test_bedrock_mantle.py::test_mantle_region_reflected_in_url PASSED
tests/llm_translation/test_bedrock_mantle.py::test_mantle_request_does_not_include_mantle_prefix_in_body PASSED
tests/llm_translation/test_bedrock_mantle.py::test_mantle_request_url_and_body PASSED

12 passed in 0.25s

Pre-Submission checklist

  • Added tests in tests/test_litellm/ (unit) and tests/llm_translation/ (e2e with mocked HTTP)
  • make test-unit passes for new tests

Type

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

CI

  • LiteLLM Tests

@CLAassistant

CLAassistant commented Apr 21, 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 sign our Contributor License Agreement before we can accept your contribution.


Ishaan Jaffer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@ghost
ghost changed the base branch from main to litellm_internal_staging April 21, 2026 22:14
@codspeed

codspeed Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Congrats! CodSpeed is installed 🎉

🆕 16 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for the bedrock/mantle/<model-id> route, routing requests to https://bedrock-mantle.{region}.api.aws/v1/messages with AWS SigV4 auth and the Anthropic Messages API body format. The routing, URL construction, model-prefix stripping, and SigV4 wiring all look correct; the 12 new tests pass and the mock-only constraint for tests/llm_translation/ is respected.

Two previously-flagged P1 issues remain unresolved in this diff:

  • strip_bedrock_routing_prefix does not strip \"mantle/\", so cost and model-info lookups for bedrock/mantle/... models return a stale key and silently produce $0 cost.
  • The sync transform_request in AmazonMantleConfig omits the _convert_document_url_sources_to_base64 call that the async path performs, silently corrupting multimodal requests on the sync path.

Confidence Score: 4/5

Safe to merge once the two open P1s from previous review rounds are addressed.

Two previously-flagged P1 issues remain unresolved: strip_bedrock_routing_prefix missing "mantle/" breaks cost/capability lookups, and the sync transform_request omits document-URL base64 conversion. These are real present defects on the changed path, not speculative concerns, keeping the score at 4.

litellm/llms/bedrock/common_utils.py (strip_bedrock_routing_prefix) and litellm/llms/bedrock/chat/mantle/transformation.py (sync document-URL conversion)

Important Files Changed

Filename Overview
litellm/llms/bedrock/chat/mantle/transformation.py New AmazonMantleConfig for /chat/completions; sync transform_request still missing _convert_document_url_sources_to_base64 (previously flagged P1), and MANTLE_ENDPOINT_TEMPLATE is duplicated with mantle_transformation.py
litellm/llms/bedrock/messages/mantle_transformation.py New AmazonMantleMessagesConfig for /messages; inherits correctly from AmazonAnthropicClaudeMessagesConfig; MANTLE_ENDPOINT_TEMPLATE constant duplicated from transformation.py
litellm/llms/bedrock/common_utils.py Adds mantle route dispatch and _explicit_mantle_route helper; strip_bedrock_routing_prefix still missing "mantle/" (previously flagged P1), causing broken cost/model-info lookups
model_prices_and_context_window.json Adds anthropic.claude-mythos-preview with correct capability flags; 0-cost placeholder is intentional pending pricing
tests/llm_translation/test_bedrock_mantle.py E2E mocked tests verifying URL, model in body, and SigV4 auth; uses proper patch.object mocking, compliant with no-real-network-calls rule
tests/test_litellm/llms/bedrock/test_mantle.py Unit tests for route detection, URL construction, and config dispatch; 9 targeted tests with good coverage of the happy path
litellm/init.py Adds TYPE_CHECKING import for AmazonMantleMessagesConfig, consistent with existing pattern
litellm/_lazy_imports_registry.py Registers AmazonMantleMessagesConfig in lazy import registry, consistent with surrounding entries

Sequence Diagram

sequenceDiagram
    participant User
    participant LiteLLM
    participant BedrockModelInfo
    participant AmazonMantleConfig
    participant MantleEndpoint as bedrock-mantle.{region}.api.aws

    User->>LiteLLM: completion(model="bedrock/mantle/anthropic.claude-mythos-preview")
    LiteLLM->>BedrockModelInfo: get_bedrock_route("mantle/...")
    BedrockModelInfo-->>LiteLLM: "mantle"
    LiteLLM->>BedrockModelInfo: get_bedrock_chat_config("mantle/...")
    BedrockModelInfo-->>LiteLLM: AmazonMantleConfig()
    LiteLLM->>AmazonMantleConfig: get_complete_url(region="us-east-1")
    AmazonMantleConfig-->>LiteLLM: "https://bedrock-mantle.us-east-1.api.aws/v1/messages"
    LiteLLM->>AmazonMantleConfig: transform_request(model="mantle/anthropic.claude-mythos-preview")
    Note over AmazonMantleConfig: strips "mantle/" prefix, adds model to body
    AmazonMantleConfig-->>LiteLLM: {model: "anthropic.claude-mythos-preview", messages: [...]}
    LiteLLM->>MantleEndpoint: POST /v1/messages (SigV4 signed, service=bedrock)
    MantleEndpoint-->>LiteLLM: Anthropic Messages API response
    LiteLLM-->>User: OpenAI-format ModelResponse
Loading

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile

Comment on lines +57 to +72
# Strip the "mantle/" routing prefix to get the real model ID
model_id = model.replace("mantle/", "", 1)

request = self._build_bedrock_anthropic_request_base(
model=model_id,
messages=messages,
optional_params=optional_params,
litellm_params=litellm_params,
headers=headers,
)
# The parent strips "model" from the body (Invoke API puts it in URL).
# The mantle endpoint (Messages API) requires "model" in the body.
request["model"] = model_id
return request

async def async_transform_request(

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.

P1 Sync transform_request skips document-URL conversion that async path performs

async_transform_request calls _async_convert_document_url_sources_to_base64(request) (line 82), but the sync transform_request never calls _convert_document_url_sources_to_base64. This means a synchronous caller passing document/image URL sources will have raw URLs in the request body, while an async caller will get them converted to base64. Because the parent class documents this step as required for any Bedrock-family endpoint ("Bedrock Invoke does not accept document URL sources"), the omission silently corrupts multimodal requests on the sync path.

else:
LiteLLMLoggingObj = Any

MANTLE_ENDPOINT_TEMPLATE = "https://bedrock-mantle.{region}.api.aws/v1/messages"

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.

P2 MANTLE_ENDPOINT_TEMPLATE duplicated across two files

The same constant is defined identically in litellm/llms/bedrock/messages/mantle_transformation.py (line 23). If the endpoint URL changes these must be kept in sync manually. Consider moving it to a shared location (e.g. importing from transformation.py into mantle_transformation.py, or into a shared bedrock/constants.py).

@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:21 — with GitHub Actions Inactive
@gitguardian

gitguardian Bot commented Apr 21, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
29203053 Triggered Generic Password 7f7fcc3 .circleci/config.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:22 — with GitHub Actions Inactive
@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:22 — with GitHub Actions Inactive
@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:22 — with GitHub Actions Inactive
@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:22 — with GitHub Actions Inactive
@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/llms/bedrock/chat/mantle/transformation.py 75.00% 5 Missing ⚠️
...llm/llms/bedrock/messages/mantle_transformation.py 71.42% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ghost
ghost merged commit a302613 into litellm_internal_staging Apr 21, 2026
101 checks passed
@ghost
ghost deleted the litellm_bedrock_mantle_ant branch April 21, 2026 22:42
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
… Preview) (BerriAI#26196)

* add anthropic.claude-mythos-preview to model_prices_and_context_window.json

* add mantle route to bedrock common_utils: route detection, chat config, messages config dispatch

* add AmazonMantleConfig for bedrock/mantle /chat/completions endpoint

* add AmazonMantleMessagesConfig for bedrock/mantle /messages endpoint

* register AmazonMantleMessagesConfig in __init__.py and lazy imports registry

* add unit tests for bedrock mantle route and config dispatch

* add e2e tests for bedrock mantle: URL, body, SigV4 header, region routing
This pull request was closed.

This branch was previously deployed

1 inactive deployment
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