Skip to content

fix(anthropic, amazon-bedrock): migrate output_format to output_config.format#12319

Merged
aayush-kapoor merged 8 commits intovercel:mainfrom
muraliavarma:fix/migrate-output-format-to-output-config
Feb 27, 2026
Merged

fix(anthropic, amazon-bedrock): migrate output_format to output_config.format#12319
aayush-kapoor merged 8 commits intovercel:mainfrom
muraliavarma:fix/migrate-output-format-to-output-config

Conversation

@muraliavarma
Copy link
Copy Markdown
Contributor

@muraliavarma muraliavarma commented Feb 6, 2026

Background

#12298

Summary

  • @ai-sdk/anthropic: Migrated the deprecated output_format request parameter to output_config.format, aligning with the current Anthropic API. 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

repro
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);
});

Related Issues

Fixes #12298

@vercel-ai-sdk vercel-ai-sdk bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider provider/anthropic Issues related to the @ai-sdk/anthropic provider labels Feb 6, 2026
@muraliavarma muraliavarma force-pushed the fix/migrate-output-format-to-output-config branch from 69096b4 to 10da013 Compare February 6, 2026 17:16
chatgpt-codex-connector[bot]

This comment was marked as spam.

…g.format and enable Bedrock structured outputs

Fixes vercel#12298
@muraliavarma muraliavarma force-pushed the fix/migrate-output-format-to-output-config branch from 10da013 to 7d78dbe Compare February 19, 2026 03:21
Copy link
Copy Markdown
Collaborator

@aayush-kapoor aayush-kapoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! look correct - just making some minor changes and will merge

});
});

it('should still use json tool fallback for structured output without thinking enabled', async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might need to change eventually. didn't change in this PR since it led to some regression after changed behaviour and would expand the scope of this PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change in this file is because bedrock now supports native structured ouptuts. using the falling back to the JSON tool approach was leading to issues when thinking was enabled. so we changed made the guard very specific to that use case for now

@dancer
Copy link
Copy Markdown
Collaborator

dancer commented Feb 27, 2026

thanks a bunch @muraliavarma 🎉

@aayush-kapoor aayush-kapoor merged commit d98d9ba into vercel:main Feb 27, 2026
17 checks passed
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

vercel-ai-sdk bot commented Feb 27, 2026

🚀 Published in:

Package Version
@ai-sdk/amazon-bedrock 4.0.68
@ai-sdk/anthropic 3.0.49
@ai-sdk/google-vertex 4.0.67

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider provider/anthropic Issues related to the @ai-sdk/anthropic provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anthropic provider sends deprecated output_format instead of output_config.format, breaking Bedrock structured outputs

3 participants