Skip to content

Anthropic Structured Output Issue #151

@johnhooks

Description

@johnhooks

Problem

When using ->asJsonResponse($schema) with the Anthropic provider, the API returns errors:

Bad Request (400) - response_format.json_schema.name: Field required # Added `name` field to schema wrapper, then got: Bad Request (400) - response_format.json_schema.strict: Field required # Added `strict: true` to schema wrapper, then got: Bad Request (400) - output_config: Extra inputs are not permitted # Anthropic doesn't recognize `response_format` at all—it's an OpenAI parameter 

The library sends OpenAI's response_format parameter to Anthropic's API, which now rejects it. This appears to have started around December 4, 2025 when Anthropic launched their structured outputs feature—prior to this, the parameter was likely ignored.

Proposed Solution

Anthropic's structured outputs use a different format than OpenAI:

OpenAI Anthropic
Parameter response_format output_format
Beta header None anthropic-beta: structured-outputs-2025-11-13

The Anthropic provider should override prepareGenerateTextParams() to:

  1. Use output_format instead of response_format
  2. Add the required beta header

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions