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
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:
@JasonTheAdams I tested this out and JSON generation is still broken on trunk. PR #156 sends the output_format param but the API rejects it with "Extra inputs are not permitted."
Structured outputs is still in beta on Anthropic's side, so you need to include the anthropic-beta: structured-outputs-2025-11-13 header. Without it, the API just doesn't recognize the parameter.
I added the header locally and it works perfectly after that.
Activity
johnhooks commentedon Dec 20, 2025
Moving to the native Anthropic API (#107) would probably be the correct way to resolve this.
johnhooks commentedon Dec 20, 2025
I've working on a solution and having something functional, if there is interest I can open a PR. https://github.com/johnhooks/php-ai-client/tree/fix/issue-151
JasonTheAdams commentedon Jan 5, 2026
Thanks, @johnhooks! Can you please confirm if this is resolved in #156?
johnhooks commentedon Jan 5, 2026
@JasonTheAdams I tested this out and JSON generation is still broken on trunk. PR #156 sends the
output_formatparam but the API rejects it with "Extra inputs are not permitted."Structured outputs is still in beta on Anthropic's side, so you need to include the
anthropic-beta: structured-outputs-2025-11-13header. Without it, the API just doesn't recognize the parameter.I added the header locally and it works perfectly after that.
https://platform.claude.com/docs/en/build-with-claude/structured-outputs
JasonTheAdams commentedon Jan 5, 2026
Got it! Would you be willing to open a PR with the fix, @johnhooks? Ideally this week. If you can't, just let me know and I'll try to knock it out. 😄