fix(anthropic): drop invalid name field from output_config.format - #33
Open
adilson0888 wants to merge 1 commit into
Open
Conversation
Anthropic's Messages API structured-output field, output_config.format,
only accepts { type, schema }. Sending the extra `name` field (carried
over from OpenAI's json_schema.name / text.format.name conventions)
causes the live API to reject every structured-output request from the
anthropic provider with:
400 output_config.format.name: Extra inputs are not permitted
Reproduced against the real API via a Karakeep auto-tagging request
routed through the anthropic provider (claude-haiku-4-5, /v1/chat/completions
with response_format.json_schema). Confirmed the fix resolves it end-to-end
against the live API, then updated the stale unit test that had asserted
the buggy behavior.
Affects both translator paths that build Anthropic requests:
- openaiToAnthropic (Chat Completions -> Anthropic)
- responsesToAnthropic (Responses API -> Anthropic)
The equivalent OpenAI-Responses-shaped output (chatToResponsesRequest,
text.format.name) is untouched -- that field is valid for OpenAI's own
Responses API and unrelated to this bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #32.
Problem
Structured-output requests (
response_format.json_schemaon/v1/chat/completions,text.formaton/v1/responses) to theanthropicprovider fail outright against the live Anthropic API:{"error":{"message":"output_config.format.name: Extra inputs are not permitted","type":"invalid_request_error"}}Anthropic's Messages API
output_config.formatonly accepts{ type, schema }. The translator was carrying over an OpenAI-stylenamefield (valid on OpenAI'sjson_schema.name/text.format.name, not on Anthropic's shape) into the Anthropic request body, and Anthropic's strict validation rejects the unrecognized field.Fix
Drops
namefrom both call sites that buildoutput_config.formatfor Anthropic:openaiToAnthropic(Chat Completions → Anthropic)responsesToAnthropic(Responses API → Anthropic)No other fields change. The equivalent OpenAI-Responses-shaped path (
chatToResponsesRequest,text.format.name) is untouched — that field is correct there, it's a different upstream (OpenAI) with a different accepted shape.Also fixes a stale unit test that had asserted the buggy behavior (
result.output_config.format.name === "test").Verification
claude-haiku-4-5,/v1/chat/completionswithresponse_format.json_schema).npm test→ 200/200.Notes
I initially mis-diagnosed this and tried renaming the field to
output_format" — Anthropic's own error message corrected that ("This field is deprecated. Use 'output_config.format' instead"), confirmingoutput_config.formatis the current wrapper and the sole problem is the extraname` key inside it. Mentioning in case anyone else goes down the same wrong path from the error text.