Description
@ai-sdk/anthropic sends the deprecated output_format parameter when using structuredOutputMode: "outputFormat". The Anthropic API has migrated to output_config.format (docs).
The direct Anthropic API still accepts output_format temporarily, but Amazon Bedrock already rejects it:
output_format: This field is deprecated. Use 'output_config.format' instead.
See https://platform.claude.com/docs/en/build-with-claude/structured-outputs for more information.
This means there is currently no way to use structured outputs with thinking/adaptive on Bedrock through the AI SDK, even though the Bedrock API fully supports it via output_config.format.
Root cause
In @ai-sdk/anthropic, the request body is built with the deprecated parameter name:
// @ai-sdk/anthropic/dist/index.mjs ~line 2599
...useStructuredOutput && responseFormat?.type === "json" && responseFormat.schema != null && {
output_format: { // <-- deprecated, should be output_config.format
type: "json_schema",
schema: responseFormat.schema
}
},
Additionally, @ai-sdk/amazon-bedrock/anthropic hardcodes supportsNativeStructuredOutput: false with the comment "force the use of JSON tool fallback for structured outputs since beta header isn't supported" — but structured outputs are now GA on Bedrock (no beta header required).
Reproduction
Full reproduction script (3 tests — 2 fail via AI SDK, 1 passes via @anthropic-ai/bedrock-sdk):
https://gist.github.com/p3droml/4b9a903054952a1095a71d88ce10ff4e
npm install ai @ai-sdk/amazon-bedrock @anthropic-ai/bedrock-sdk zod tsx
# Set AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
npx tsx test-bedrock-structured-output.ts
Output:
1. AI SDK — bedrock (Converse API)
✗ FAILED: Thinking may not be enabled when tool_choice forces tool use.
2. AI SDK — bedrockAnthropic (Invoke API, structuredOutputMode: outputFormat)
✗ FAILED: output_format: This field is deprecated. Use 'output_config.format' instead.
3. @anthropic-ai/bedrock-sdk — output_config.format (native SDK)
Output: { answer: 'Love is a deep emotional bond...' }
✓ PASSED
Suggested fix
- In
@ai-sdk/anthropic: rename output_format to output_config.format in the request body
- In
@ai-sdk/amazon-bedrock/anthropic: set supportsNativeStructuredOutput: true (structured outputs are GA on Bedrock, no beta header needed)
AI SDK Version
ai: 6.0.72
@ai-sdk/anthropic: 3.0.37
@ai-sdk/amazon-bedrock: 4.0.49
@anthropic-ai/bedrock-sdk: 0.26.3 (used to verify Bedrock API works)
Description
@ai-sdk/anthropicsends the deprecatedoutput_formatparameter when usingstructuredOutputMode: "outputFormat". The Anthropic API has migrated tooutput_config.format(docs).The direct Anthropic API still accepts
output_formattemporarily, but Amazon Bedrock already rejects it:This means there is currently no way to use structured outputs with thinking/adaptive on Bedrock through the AI SDK, even though the Bedrock API fully supports it via
output_config.format.Root cause
In
@ai-sdk/anthropic, the request body is built with the deprecated parameter name:Additionally,
@ai-sdk/amazon-bedrock/anthropichardcodessupportsNativeStructuredOutput: falsewith the comment "force the use of JSON tool fallback for structured outputs since beta header isn't supported" — but structured outputs are now GA on Bedrock (no beta header required).Reproduction
Full reproduction script (3 tests — 2 fail via AI SDK, 1 passes via
@anthropic-ai/bedrock-sdk):https://gist.github.com/p3droml/4b9a903054952a1095a71d88ce10ff4e
npm install ai @ai-sdk/amazon-bedrock @anthropic-ai/bedrock-sdk zod tsx # Set AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY npx tsx test-bedrock-structured-output.tsOutput:
Suggested fix
@ai-sdk/anthropic: renameoutput_formattooutput_config.formatin the request body@ai-sdk/amazon-bedrock/anthropic: setsupportsNativeStructuredOutput: true(structured outputs are GA on Bedrock, no beta header needed)AI SDK Version
ai: 6.0.72@ai-sdk/anthropic: 3.0.37@ai-sdk/amazon-bedrock: 4.0.49@anthropic-ai/bedrock-sdk: 0.26.3 (used to verify Bedrock API works)