fix(amazon-bedrock): disable native structured output for claude-opus-4-7#15288
Merged
aayush-kapoor merged 3 commits intoMay 15, 2026
Merged
Conversation
…-4-7 Bedrock rejects `output_config.format` for `claude-opus-4-7` (including the `us.`/`eu.` cross-region inference profiles) with: output_config.format: Extra inputs are not permitted The provider previously hardcoded `supportsNativeStructuredOutput: true` for every Bedrock-Anthropic model, so any `output` / `Output.object(...)` call against opus-4-7 (e.g. with reasoning enabled) failed before the model ran. Drop the flag for opus-4-7 so the SDK uses the `jsonResponseTool` fallback, which Bedrock accepts. Other Bedrock-Anthropic models are unchanged. Fixes vercel#14773
aayush-kapoor
approved these changes
May 15, 2026
Collaborator
|
verified that the fix works for the following example import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
import { generateText, Output } from 'ai';
import 'dotenv/config';
import { z } from 'zod';
import { run } from '../../lib/run';
run(async () => {
const result = await generateText({
model: bedrockAnthropic('global.anthropic.claude-opus-4-7'),
output: Output.object({
schema: z.object({
recipe: z.object({
name: z.string(),
ingredients: z.array(
z.object({
name: z.string(),
amount: z.string(),
}),
),
steps: z.array(z.string()),
}),
}),
}),
prompt: 'Generate a lasagna recipe.',
});
console.log('Recipe:', JSON.stringify(result.output, null, 2));
console.log();
console.log('Finish reason:', result.finishReason);
console.log('Usage:', result.usage);
});thanks! |
aayush-kapoor
approved these changes
May 15, 2026
Contributor
|
🚀 Published in:
|
github-actions Bot
added a commit
that referenced
this pull request
May 15, 2026
…-4-7 (#15288) ## Summary Fixes #14773. Bedrock rejects `output_config.format` for `claude-opus-4-7` (including the `us.`/`eu.` cross-region inference profiles) with: ``` output_config.format: Extra inputs are not permitted ``` `packages/amazon-bedrock/src/anthropic/amazon-bedrock-anthropic-provider.ts` previously hardcoded `supportsNativeStructuredOutput: true` for every Bedrock-Anthropic model. The Anthropic capability table already lists opus-4-7 as supporting structured output, so the SDK took the native path that Bedrock then refused, and any `output` / `Output.object(...)` call against opus-4-7 (including reasoning runs) failed before the model ran. This changes the flag to `!modelId.includes('claude-opus-4-7')`. Other Bedrock-Anthropic models stay on the native path; opus-4-7 falls back to the `jsonResponseTool` path, which Bedrock accepts. Using `includes()` covers the direct `anthropic.claude-opus-4-7` id and both cross-region inference profiles (`us.anthropic.claude-opus-4-7`, `eu.anthropic.claude-opus-4-7`). ## Test plan - [x] Added a parameterized test for the direct id and both cross-region prefixes. The existing default-model assertion still requires `supportsNativeStructuredOutput: true` for non-opus-4-7 models. - [x] `pnpm --filter @ai-sdk/amazon-bedrock test`: 369/369 pass (node + edge) - [x] `pnpm check`: lint and format clean - [x] `pnpm --filter @ai-sdk/amazon-bedrock type-check` --------- Co-authored-by: Aayush Kapoor <aayushkapoor34@gmail.com>
Contributor
|
✅ Backport PR created: #15352 |
aayush-kapoor
added a commit
that referenced
this pull request
May 15, 2026
…laude-opus-4-7 (#15352) This is an automated backport of #15288 to the release-v6.0 branch. FYI @zxuhan --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Aayush Kapoor <aayushkapoor34@gmail.com> Co-authored-by: Aayush Kapoor <83492835+aayush-kapoor@users.noreply.github.com> Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #14773.
Bedrock rejects
output_config.formatforclaude-opus-4-7(including theus./eu.cross-region inference profiles) with:packages/amazon-bedrock/src/anthropic/amazon-bedrock-anthropic-provider.tspreviously hardcodedsupportsNativeStructuredOutput: truefor every Bedrock-Anthropic model. The Anthropic capability table already lists opus-4-7 as supporting structured output, so the SDK took the native path that Bedrock then refused, and anyoutput/Output.object(...)call against opus-4-7 (including reasoning runs) failed before the model ran.This changes the flag to
!modelId.includes('claude-opus-4-7'). Other Bedrock-Anthropic models stay on the native path; opus-4-7 falls back to thejsonResponseToolpath, which Bedrock accepts. Usingincludes()covers the directanthropic.claude-opus-4-7id and both cross-region inference profiles (us.anthropic.claude-opus-4-7,eu.anthropic.claude-opus-4-7).Test plan
supportsNativeStructuredOutput: truefor non-opus-4-7 models.pnpm --filter @ai-sdk/amazon-bedrock test: 369/369 pass (node + edge)pnpm check: lint and format cleanpnpm --filter @ai-sdk/amazon-bedrock type-check