You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d98d9ba
Browse filesBrowse the repository at this point in the historyBrowse files
fix(anthropic, amazon-bedrock): migrate output_format to output_config.format (#12319)
## Background
#12298
## Summary
- **`@ai-sdk/anthropic`**: Migrated the deprecated `output_format`
request parameter to `output_config.format`, aligning with the [current
Anthropic
API](https://platform.claude.com/docs/en/build-with-claude/structured-outputs).
The `effort` and `format` fields are now merged into a single
`output_config` object to avoid one spread overwriting the other.
- **`@ai-sdk/amazon-bedrock`**: Enabled `supportsNativeStructuredOutput:
true` for Bedrock Anthropic models. Structured outputs are now GA on
Bedrock and no longer require a beta header, so the JSON tool fallback
is no longer necessary.
## Manual Verification
verified the fix by running the following code snippet before and after
the changes
<Details>
<summary> repro </summary>
```ts
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('us.anthropic.claude-opus-4-6-v1'),
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()),
}),
}),
}),
providerOptions: {
anthropic: {
structuredOutputMode: "outputFormat",
thinking: { type: "adaptive" },
effort: "low",
},
},
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);
});
```
</Details>
## Related Issues
Fixes#12298
---------
Co-authored-by: Aayush Kapoor <[email protected]>
Co-authored-by: Aayush Kapoor <[email protected]>
Migrated deprecated `output_format` parameter to `output_config.format` for structured outputs + Enabled native structured output support for Bedrock Anthropic models via `output_config.format`.
0 commit comments