Skip to content

[Bug]: Anthropic structured output (response_format.json_schema) fails with "output_config.format.name: Extra inputs are not permitted" #32

Description

@adilson0888

What happened?

Any request to the anthropic provider using structured JSON output — response_format.json_schema on /v1/chat/completions, or text.format on /v1/responses — fails with a 400 from the real upstream Anthropic API:

{"type":"error","error":{"type":"invalid_request_error","message":"output_config.format.name: Extra inputs are not permitted"},"request_id":"req_011Ce2pcdhDimKeeDjRZViSw"}

Root cause

src/upstream/translator.ts builds the outbound Anthropic request as:

anthropicBody.output_config = {
  format: {
    type: "json_schema",
    schema: fmt.json_schema.schema,
    name: fmt.json_schema.name,   // <-- rejected by Anthropic
  },
};

Anthropic's Messages API output_config.format only accepts { type, schema } — it has no name field (unlike OpenAI's json_schema.name / text.format.name, which this code is clearly translating from). Sending the extra field trips Anthropic's strict schema validation and every structured-output request to the anthropic provider fails outright.

This hits both translator paths that build Anthropic requests:

  • openaiToAnthropic (Chat Completions → Anthropic) — line ~200
  • responsesToAnthropic (Responses API → Anthropic) — line ~579

(The equivalent OpenAI-Responses-shaped output in chatToResponsesRequest / text.format.name is unaffected — that field is valid for OpenAI's own Responses API and is a separate code path.)

Steps to reproduce

  1. Log in with --provider=anthropic.
  2. Send a chat completion with a JSON-schema response format, e.g. (this is the exact request that reproduced it, via Karakeep's auto-tagging feature):
curl -s http://127.0.0.1:8317/v1/chat/completions \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "messages": [{"role":"user","content":"Extract tags for: a tutorial about docker compose networking"}],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "tags",
        "schema": {"type":"object","additionalProperties":false,"properties":{"tags":{"type":"array","items":{"type":"string"}}},"required":["tags"]}
      }
    }
  }'
  1. Observe the 400 above instead of a completion.

Fix

PR incoming: drops the name field from both output_config.format construction sites. Verified against the live Anthropic API — same request as above now returns a real completion instead of a 400. Also updated tests/unit.test.ts, which had a stale assertion (`result.output_config.format.name === "test"") enshrining the buggy shape.

What LiteLLM/auth2api version are you on?

Reproduced against main as of 2026-08-14.

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions