Skip to content

fix(amazon-bedrock): disable native structured output for claude-opus-4-7#15288

Merged
aayush-kapoor merged 3 commits into
vercel:mainfrom
zxuhan:fix/bedrock-opus-4-7-native-structured-output
May 15, 2026
Merged

fix(amazon-bedrock): disable native structured output for claude-opus-4-7#15288
aayush-kapoor merged 3 commits into
vercel:mainfrom
zxuhan:fix/bedrock-opus-4-7-native-structured-output

Conversation

@zxuhan
Copy link
Copy Markdown
Contributor

@zxuhan zxuhan commented May 14, 2026

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

  • 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.
  • pnpm --filter @ai-sdk/amazon-bedrock test: 369/369 pass (node + edge)
  • pnpm check: lint and format clean
  • pnpm --filter @ai-sdk/amazon-bedrock type-check

…-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
Copy link
Copy Markdown
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 aayush-kapoor added the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 15, 2026
@aayush-kapoor aayush-kapoor enabled auto-merge (squash) May 15, 2026 18:21
@aayush-kapoor aayush-kapoor disabled auto-merge May 15, 2026 18:28
@aayush-kapoor aayush-kapoor enabled auto-merge (squash) May 15, 2026 18:28
@aayush-kapoor aayush-kapoor merged commit b555b23 into vercel:main May 15, 2026
18 of 19 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.0-canary.140
@ai-sdk/amazon-bedrock 5.0.0-canary.63
@ai-sdk/angular 3.0.0-canary.140
@ai-sdk/azure 4.0.0-canary.59
@ai-sdk/gateway 4.0.0-canary.83
@ai-sdk/google 4.0.0-canary.64
@ai-sdk/google-vertex 5.0.0-canary.83
@ai-sdk/langchain 3.0.0-canary.140
@ai-sdk/llamaindex 3.0.0-canary.140
@ai-sdk/openai 4.0.0-canary.59
@ai-sdk/otel 1.0.0-canary.86
@ai-sdk/react 4.0.0-canary.141
@ai-sdk/rsc 3.0.0-canary.141
@ai-sdk/svelte 5.0.0-canary.140
@ai-sdk/vue 4.0.0-canary.140
@ai-sdk/workflow 1.0.0-canary.57

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>
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label May 15, 2026
@github-actions
Copy link
Copy Markdown
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>
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.

Bedrock rejects output_config.format on claude-opus-4-7 when SDK uses native structured output

2 participants