Skip to content

docs(providers_anthropic): Opus 4.1 uses the json_tool_call fallback, not native output_format - #1852

Merged
devin-ai-integration[bot] merged 1 commit into
mainfrom
litellm_docs_lit8756
Sep 28, 2026
Merged

devin-ai-integration[bot] merged 1 commit into
mainfrom
litellm_docs_lit8756

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The Anthropic provider page listed Claude Opus 4.1 as a native structured output model, saying response_format is translated to Anthropic output_format for it. On current litellm main, AnthropicConfig.map_openai_params only takes the native path when supports_native_structured_output is set in the cost map, and no claude-opus-4-1* Anthropic entry carries that flag (the direct Anthropic entries were removed from the cost map after their deprecation date in BerriAI/litellm#42435). Opus 4.1 requests therefore go through the json_tool_call forced tool fallback with no structured outputs beta header. The flag is set for Sonnet 4.5 and later, Opus 4.5 and later, and Haiku 4.5, and those are the models that get output_format

The page now lists those models as native, says Opus 4.1 and older use the json_tool_call fallback, and fixes the info box, which named the target field output_schema and described the tool fallback as part of the native path. Live test against real Anthropic confirmed the old text was wrong: Opus 4.1 got the tool fallback and no output_format, while Sonnet 4.5, Opus 4.5 and Haiku 4.5 got output_format plus the structured-outputs-2025-11-13 header and returned schema-valid JSON. Anthropic's API now returns not_found_error for claude-opus-4-1-20250805, which is a separate staleness issue with the model list at the top of the page and is not changed here

Linear ticket

Resolves LIT-8756

Live evidence

litellm main at 6f5ad78a1f, real Anthropic API, no stubs

SDK run, capturing the outbound Anthropic request body and headers via a CustomLogger.log_pre_api_call hook, with the doc's capital_response schema:

litellm.completion(model="anthropic/<m>", messages=[...], response_format=<capital_response json_schema>, max_tokens=100)

claude-opus-4-1-20250805: output_format=False tools=['json_tool_call'] tool_choice={'name': 'json_tool_call', 'type': 'tool'} beta=None
  -> NotFoundError: AnthropicException - {"type":"error","error":{"type":"not_found_error","message":"model: claude-opus-4-1-20250805"}}
claude-sonnet-4-5-20250929: output_format=True tools=[] tool_choice=None beta=structured-outputs-2025-11-13
  -> {"country":"France","capital":"Paris"}
claude-opus-4-5-20251101: output_format=True tools=[] tool_choice=None beta=structured-outputs-2025-11-13
  -> {"country":"France","capital":"Paris"}
claude-haiku-4-5-20251001: output_format=True tools=[] tool_choice=None beta=structured-outputs-2025-11-13
  -> {"country":"France","capital":"Paris"}

Proxy run (uv run python litellm/proxy/proxy_cli.py --config cfg.yaml --port 4000 --detailed_debug, claude-opus-4-1 -> anthropic/claude-opus-4-1-20250805, claude-sonnet-4-5 -> anthropic/claude-sonnet-4-5-20250929), using the doc's curl:

$ curl localhost:4000/v1/chat/completions -H "Authorization: Bearer sk-1234" -d '{"model":"claude-opus-4-1", ... "response_format": {...}}'
{"error":{"message":"litellm.NotFoundError: AnthropicException - ... \"model: claude-opus-4-1-20250805\" ..."}}
$ curl ... '{"model":"claude-sonnet-4-5", ...}'
{"model":"claude-sonnet-4-5", ..."message":{"content":"{\"country\":\"France\",\"capital\":\"Paris\"}", ...}}

$ grep debug log for the outbound request bodies
'tool_choice': {'name': 'json_tool_call', 'type': 'tool'      <- opus 4.1
'output_format': {'type': 'json_schema', 'schema': {...        <- sonnet 4.5
anthropic-beta: structured-outputs-2025-11-13                  <- sonnet 4.5 only

Cost map on main: supports_native_structured_output: true on claude-sonnet-4-5, claude-sonnet-4-6, claude-sonnet-5, claude-haiku-4-5, claude-opus-4-5, claude-opus-4-6, claude-opus-4-7, claude-opus-4-8, claude-opus-5, claude-opus-5-5. No anthropic claude-opus-4-1* entry exists, and the bedrock Opus 4.1 entries do not set the flag

Link to Devin session: https://app.devin.ai/sessions/4f05b13c62e24eadb57f2016c4d3b4f4
Open in Devin Desktop: https://app.devin.ai/desktop/session/4f05b13c62e24eadb57f2016c4d3b4f4?variant=devin
Requested by: @jesus-berri

… not native output_format

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@vercel

vercel Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
litellm Ready Ready Preview Sep 28, 2026 5:11pm UTC

Request Review

@devin-ai-integration
devin-ai-integration Bot merged commit cc7f60b into main Sep 28, 2026
4 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the litellm_docs_lit8756 branch September 28, 2026 17:32

This branch was successfully deployed

1 active deployment
Preview — 4fba77dd Deployed Sep 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant