Skip to content

Conversation

@lgrammel
Copy link
Collaborator

@lgrammel lgrammel commented Nov 23, 2025

Background

Anthropic has introduced structured outputs for Claude Sonnet 4.5 and Claude Opus 4.1

https://platform.claude.com/docs/en/build-with-claude/structured-outputs

Summary

  • enable using output_format for supported models
  • introduce structuredOutputMode provider option with outputFormat, jsonTool, auto settings

Manual Verification

  • run examples/ai-core/src/generate-object/anthropic.ts and check call uses output_format
  • run examples/ai-core/src/stream-object/anthropic.ts and check call uses output_format
  • run examples/ai-core/src/stream-text/anthropic-output-object.ts and check call uses output_format

Tasks

  • add setting
  • document setting
  • test various cases with setting
    • sonnet 4.5 default generate
    • sonnet 4.5 default stream
    • sonnet 4 default
    • sonnet 4.5 off
    • unknown model on

Future Work

@gr2m gr2m added the feature New feature or request label Nov 24, 2025
@lgrammel lgrammel changed the title anthropic strict tool outputs anthropic json output Nov 24, 2025
@lgrammel lgrammel changed the title anthropic json output feat(provider/anthropic): Anthropic-native structured outputs Nov 24, 2025
@lgrammel lgrammel marked this pull request as ready for review November 24, 2025 12:57
@lgrammel lgrammel merged commit b8ea36e into main Nov 24, 2025
19 checks passed
@lgrammel lgrammel deleted the lg/qtOQq1me branch November 24, 2025 14:11
@gr2m gr2m added the backport label Nov 24, 2025
vercel-ai-sdk bot pushed a commit that referenced this pull request Nov 24, 2025
@vercel-ai-sdk vercel-ai-sdk bot removed the backport label Nov 24, 2025
@vercel-ai-sdk

This comment was marked as outdated.

@vercel-ai-sdk
Copy link
Contributor

vercel-ai-sdk bot commented Nov 24, 2025

⚠️ Backport to release-v5.0 created but has conflicts: #10552

lgrammel added a commit that referenced this pull request Nov 25, 2025
…ts (#10552) This is a backport of #10502 to the release-v5.0 branch. The default for output format usage has been changed to `jsonTool`. --------- Co-authored-by: Lars Grammel <lars.grammel@gmail.com> Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
@TigerHix
Copy link

TigerHix commented Dec 2, 2025

Thanks for the update. Any ETA on the strict: true parameter for tool calls / any workarounds? Just hit this issue after migrating to AI SDK from Anthropic's SDK. :(

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

Labels

5 participants