Skip to content

[FEATURE] Route the TypeScript AnthropicModel through the Amazon Bedrock Mantle endpoint #3835

Description

@moritalous

SDK Language

TypeScript

Problem Statement

Amazon Bedrock serves Claude models through the Anthropic Messages API on the bedrock-mantle endpoint (https://bedrock-mantle.{region}.api.aws/anthropic), billing through the caller's AWS account rather than an Anthropic API key. The TypeScript AnthropicModel has no configuration for it.

Two escape hatches exist today and neither reaches the AWS credential chain.

Pointing the direct client at the endpoint works, but authenticates only with a static API key string:

new AnthropicModel({
  modelId: 'anthropic.claude-sonnet-5',
  maxTokens: 1028,
  apiKey: '<BEDROCK_API_KEY>',
  clientConfig: { baseURL: 'https://bedrock-mantle.us-east-1.api.aws/anthropic' },
})

Passing a pre-built Mantle client through the client option does not compile, because AnthropicBedrockMantle and Anthropic are siblings rather than subtypes:

error TS2739: Type 'AnthropicBedrockMantle' is missing the following properties
from type 'Anthropic': completions, models

So there is no way to select SigV4 signing, which is what makes instance roles, SSO sessions, and assumed roles usable.

OpenAIModel already exposes bedrockMantleConfig for the OpenAI-compatible side of the same endpoint, and the Python AnthropicModel is gaining the same option in #3832. The TypeScript Anthropic provider is the remaining gap.

Proposed Solution

Add a bedrockMantleConfig option to AnthropicModel, matching the name OpenAIModel already uses:

new AnthropicModel({
  modelId: 'anthropic.claude-sonnet-5',
  maxTokens: 1028,
  bedrockMantleConfig: { region: 'us-east-1' },
})

When set, the model builds AnthropicBedrockMantle instead of the direct client. That client derives the base URL from the region, sends the required anthropic-version header, and signs each request with SigV4, so no bearer token has to be minted or refreshed. The config accepts region, profile, and apiKey; supplying none of them falls back to the standard AWS credential chain.

Two constraints shape the implementation:

  • The Mantle client ships in a separate package, @anthropic-ai/bedrock-sdk, which requires @anthropic-ai/sdk >=0.115.1. The current peer range is ^0.109.1, and the two do not overlap, so the range has to move. The new package should be an optional peer dependency loaded on first use, so applications that only call the direct API do not need it installed.
  • MODEL_DEFAULTS.anthropic.modelId is claude-sonnet-4-6, which Mantle does not serve. Omitting modelId while routing through Mantle would fail with a 404 that the existing default-model warning does not predict, so the default needs to be Mantle-aware.

The region is interpolated into the endpoint URL, so it should go through the same anchored validation the OpenAI Mantle path already applies.

Use Case

  • Running Claude models against an AWS account's existing Bedrock spend and quotas instead of a separate Anthropic API key.
  • Agents on EC2/ECS/Lambda authenticating with the instance or task role, with no long-lived credential to distribute or rotate.
  • Local development against an SSO profile.
  • Deployments that need in-region inference for data residency.

Alternatives Solutions

  • Widen the client option to accept BaseAnthropic so callers can construct the Mantle client themselves. Smaller change, but it pushes the region, base URL, package installation, and version-header details onto every caller, and diverges from how OpenAIModel exposes the same endpoint.
  • Document the clientConfig.baseURL workaround instead. No code change, but it stays static-API-key-only and leaves TypeScript behind Python and behind the TypeScript OpenAI provider.

Additional Context

Endpoint reference: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-messages-api.html

Python counterpart: #3832

The Mantle catalog uses anthropic.-prefixed model IDs that differ from the direct API (anthropic.claude-sonnet-5, anthropic.claude-opus-4-8, anthropic.claude-haiku-4-5, and others), and the available set varies by region.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageRelated to new language developmentarea-modelRelated to models or model providersenhancementNew feature or requesttypescriptPull requests that update typescript code

    Fields

    Language

    TypeScript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions