Skip to content

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

Closed
ghost wants to merge 7 commits into
litellm_internal_stagingfrom
worktree-temporal-sauteeing-kahan
Closed

ghost wants to merge 7 commits into
litellm_internal_stagingfrom
worktree-temporal-sauteeing-kahan

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.

@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!

@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, which targets the new bedrock-mantle.{region}.api.aws endpoint serving Claude Mythos Preview using the raw Anthropic Messages API format with AWS SigV4 auth. The implementation is clean and follows existing explicit-route patterns (converse/, agentcore/), with both /chat/completions and /messages paths covered and unit + mocked E2E tests included.

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 style/maintenance suggestions with no impact on runtime correctness.

Route dispatch, URL construction, model-prefix stripping, SigV4 auth, and response flow are all correct. No P0/P1 issues found.

No files require special attention, though the duplicated MANTLE_ENDPOINT_TEMPLATE across chat and messages transformation files is worth cleaning up.

Important Files Changed

Filename Overview
litellm/llms/bedrock/chat/mantle/transformation.py Adds AmazonMantleConfig for /chat/completions; correctly overrides URL construction and strips the "mantle/" prefix before placing model ID in the body. MANTLE_ENDPOINT_TEMPLATE is duplicated from the messages sibling file.
litellm/llms/bedrock/messages/mantle_transformation.py Adds AmazonMantleMessagesConfig for /messages; delegates to parent and re-injects model in the body after the parent strips it. Logic is correct; shares the duplicated MANTLE_ENDPOINT_TEMPLATE constant.
litellm/llms/bedrock/common_utils.py Route dispatch for mantle added in get_bedrock_route, get_bedrock_chat_config, and get_bedrock_provider_config_for_messages_api. Consistent with existing explicit routes; minor concern with substring vs prefix check in _explicit_mantle_route.
tests/llm_translation/test_bedrock_mantle.py E2E mocked tests verify URL, model body, and SigV4 header. Broad except Exception: pass around the completion call can mask response-parsing regressions.
tests/test_litellm/llms/bedrock/test_mantle.py Unit tests cover route detection, URL construction, config dispatch, and prefix stripping for both /chat/completions and /messages. Solid coverage with no real network calls.
model_prices_and_context_window.json Adds anthropic.claude-mythos-preview with 1M context, 128K output, zero cost (TBD), and correct capability flags.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["litellm.completion(model='bedrock/mantle/...')"] --> B["BedrockModelInfo.get_bedrock_route()"]
    B -->|"'mantle/' in model"| C["route = 'mantle'"]
    C --> D["get_bedrock_chat_config()"]
    D --> E["AmazonMantleConfig"]
    E --> F["get_complete_url()\n→ bedrock-mantle.{region}.api.aws/v1/messages"]
    E --> G["transform_request()\n→ strip 'mantle/' prefix\n→ add model to body"]
    G --> H["AWS SigV4 signing\nservice=bedrock"]
    H --> I["POST bedrock-mantle.{region}.api.aws/v1/messages"]

    J["litellm.anthropic_messages(model='bedrock/mantle/...')"] --> K["BedrockModelInfo.get_bedrock_provider_config_for_messages_api()"]
    K -->|"_explicit_mantle_route(model)"| L["AmazonMantleMessagesConfig"]
    L --> M["get_complete_url()\n→ same endpoint"]
    L --> N["transform_anthropic_messages_request()\n→ strip prefix, inject model in body"]
    N --> H
Loading

Reviews (1): Last reviewed commit: "add e2e tests for bedrock mantle: URL, b..." | Re-trigger Greptile

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 Duplicated endpoint constant

MANTLE_ENDPOINT_TEMPLATE is defined identically in both chat/mantle/transformation.py (line 24) and messages/mantle_transformation.py (line 23). If the mantle endpoint URL changes, both files must be updated in sync. Consider extracting it to common_utils.py or a shared mantle_utils.py and importing it in both places.

# common_utils.py (or a new mantle_utils.py)
MANTLE_ENDPOINT_TEMPLATE = "https://bedrock-mantle.{region}.api.aws/v1/messages"

Comment on lines +67 to +69
)
except Exception:
pass # response parsing may fail on mock; we only care about the outgoing call

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 Broad exception swallow can hide response-parsing regressions

All three tests swallow every exception from litellm.completion() with except Exception: pass, and then make assertions solely about the outgoing HTTP call. If the mantle config's response-parsing breaks (e.g., the parent AmazonAnthropicClaudeConfig unwraps a Bedrock-Invoke-style envelope that the raw Anthropic response doesn't have), the exception would be silently discarded and the test would still green. Consider either:

  • Asserting the return value of litellm.completion() is a valid ModelResponse, or
  • Narrowing the except to known mock-induced errors and re-raising anything unexpected.

"""
Check if the model is an explicit mantle route (bedrock-mantle endpoint).
"""
return "mantle/" in model

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 Substring match instead of prefix check for mantle route

_explicit_mantle_route uses "mantle/" in model, consistent with other _explicit_*_route helpers, but this matches anywhere in the string. A hypothetical model name such as "us.dismantled/foo" would incorrectly be treated as a mantle route. Using model.startswith("mantle/") (or checking the segment after the provider prefix) would be more precise.

@ghost
ghost had a problem deploying to integration-postgres April 21, 2026 22:12 — with GitHub Actions Error
@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:12 — with GitHub Actions Inactive
@ghost
ghost had a problem deploying to integration-postgres April 21, 2026 22:12 — with GitHub Actions Error
@ghost
ghost temporarily deployed to integration-postgres April 21, 2026 22:12 — with GitHub Actions Inactive
@ghost

ghost commented Apr 21, 2026

Copy link
Copy Markdown
Author

Refiled as #26196 targeting main instead of litellm_internal_staging.

@ghost ghost closed this Apr 21, 2026
@devin-ai-integration
devin-ai-integration Bot deleted the worktree-temporal-sauteeing-kahan branch September 10, 2026 03:41
This pull request was closed.

This branch was previously deployed

1 inactive deployment
integration-postgres — 66faff00 Deployed Apr 21, 2026 by ghost via security / Run tests #1489
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.

1 participant