Uh oh!
There was an error while loading. Please reload this page.
feat: support Claude models on the Bedrock Mantle endpoint - #43231
feat: support Claude models on the Bedrock Mantle endpoint#43231ktoulgaridis wants to merge 10 commits into
Conversation
Mantle serves Claude through the Anthropic Messages API at /anthropic/v1/messages, which no bundled provider could reach: the mantle export is OpenAI-compatible only, and the anthropic export builds bedrock-runtime invoke paths. Adds a mantle-anthropic provider that signs Messages requests with SigV4 so profile/SSO/IRSA credentials work.
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Enough1122
commented
Aug 21, 2026
|
The new npm key was invisible to the transform layer, so Claude on Mantle got no reasoning variants, providerOptions were never remapped to the anthropic key, and the empty-content and tool-result-media checks skipped it. Mantle also rejects two fields the SDK sends by default: output_config.format (400 on any generateObject call) and a tool-level strict field. Both are model config settings, so the model is now built from @ai-sdk/anthropic/internal the same way @ai-sdk/google-vertex/anthropic builds its own.
ktoulgaridis
commented
Aug 21, 2026
Thanks — 4 is fair, added. On the rest: 1. The credential chain isn't meant to live in There was a real gap next door, now closed: unlike 2. Unreachable today: 3. Retries re-enter 4. Added. Your review pointed at the right file, though, and digging there turned up two real 400s I've now fixed:
Reaching those flags means building Separately, and bigger than any of the above: the new npm key was invisible to the transform layer, so reasoning/effort variants were never generated, |
Issue for this PR
Closes#43230
Type of change
What does this PR do?
Lets Claude models be used on the
bedrock-mantleendpoint.Mantle serves Claude only through the Anthropic Messages API at
/anthropic/v1/messages, and nothing bundled reaches that:@ai-sdk/amazon-bedrock/mantleis OpenAI-compatible only, and Mantle rejects Anthropic IDs there —The model 'anthropic.claude-opus-4-8' does not support the '/openai/v1/responses' API@ai-sdk/amazon-bedrock/anthropicspeaks Messages, but hardcodesbuildRequestUrlto thebedrock-runtime/model/{id}/invokepath and moves the model ID into ananthropic_versionbody field@ai-sdk/anthropicspeaks Messages and takes abaseURL, but authenticates only with a key, so profile/SSO users would need a Bedrock API key refreshed every 12hSo this adds
@ai-sdk/amazon-bedrock/mantle-anthropic:AnthropicMessagesLanguageModelpointed at the Mantle base URL, with afetchthat SigV4-signs the request (servicebedrock-mantle) using the credential provider the bedrock loader already builds fromregion/profile. Signing infetchis the only request-time auth hook the AI SDK offers; it wraps thefetchopencode already puts in options, so the existing timeout and SSE-abort handling still runs. Bearer tokens (AWS_BEARER_TOKEN_BEDROCKoroptions.apiKey) keep their current precedence and skip signing.Two fields the SDK sends by default are rejected by Mantle, both verified live:
output_config.format→ 400Extra inputs are not permitted, which broke everygenerateObjectcall (e.g.agent create).supportsNativeStructuredOutput: falseroutes structured output through the SDK's JSON tool instead.strictfield → 400tools.0.custom.strict: Extra inputs are not permitted, sosupportsStrictTools: falseis set too.Both are model-config-only settings, so the model is built from the declared
@ai-sdk/anthropic/internalsubpath rather thancreateAnthropic— the same way@ai-sdk/google-vertex/anthropicbuilds its model. One visible consequence: requests no longer carry theai-sdk/anthropic/<version>User-Agent suffix (@ai-sdk/google-vertex/anthropicdrops it too).provider.toolsand the embedding/image model stubs go with it; nothing here uses them.The key also has to be threaded through the Anthropic paths in the transform layer, alongside
@ai-sdk/google-vertex/anthropic—sdkKey(otherwise per-modelproviderOptionsare silently dropped), the empty-content guard,usesAnthropicAutomaticCaching,variants/reasoningEffort/reasoningBudget(otherwise reasoning is silently off),supportsMediaInToolResult, and the v1 config lowerers. The Responses-API-only lists correctly exclude it.Base URL is derived from
region, so noapioverride is needed — that also keeps it working on v2, where${AWS_REGION}is not substituted (#40075). Model IDs pass through unprefixed, since Mantle has no cross-region inference profiles.{ "provider": { "amazon-bedrock": { "options": { "region": "us-east-1", "profile": "my-sso-profile" }, "models": { "anthropic.claude-opus-4-8": { "provider": { "npm": "@ai-sdk/amazon-bedrock/mantle-anthropic" } } } } } }Related: #36208 (native llm layer design — this is the AI SDK path), #39325 (Mantle selector keyed to the
amazon-bedrockprovider id).How did you verify your code works?
bun typecheckclean inpackages/coreandpackages/opencode; full suites green (packages/core1101 pass,packages/opencode3322 pass)strict; plus the transform-layer edits and both the v1 and v2 wirings. Every production edit was mutation-tested — reverting any one of them fails a test../packages/opencode/script/build.ts --single:anthropic.claude-opus-4-8andanthropic.claude-opus-5answer over Mantle, tool calls execute and their real output is used,--variant high --thinkingstreams reasoning, andagent create(the path that previously 400'd) writes a schema-valid agent file.openai.gpt-5.6-solstill works, so the existing Mantle OpenAI route is unaffected.thinking.type: "enabled"is rejected on Opus 4.8/Opus 5/Sonnet 5 (accepted on Haiku 4.5), while adaptive thinking withoutput_config.effortis accepted.aws sso login --profile <profile>, add the config above, thenopencode run -m amazon-bedrock/anthropic.claude-opus-4-8 "hi"Note:
packages/core/test/plugin/provider-amazon-bedrock.test.tsalready fails ondevwhen run as a single file (TDZ onAmazonBedrockPluginvia a circular import); it passes as part ofbun test test/plugin. Untouched here.Screenshots / recordings
Not a UI change.
Checklist