- Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
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:
- Use
output_formatinstead ofresponse_format - Add the required beta header
References
Metadata
Metadata
Assignees
Labels
No labels