litellm - ✅(Solved) Fix [Bug]: Structured Output fails for Anthropic models on bedrock/converse [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#27846Fetched 2026-05-14 03:30:14
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Error Message

BedrockException - {"message":"The model returned the following errors: output_config.format: Extra inputs are not permitted"}

Fix Action

Fixed

PR fix notes

PR #27876: fix(bedrock): exclude Anthropic models from native structured outputs on Converse

Description (problem / solution / changelog)

Relevant issues

Fixes #27846

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

Problem

When using the Responses API with Bedrock Converse + Anthropic models (e.g. bedrock/converse/eu.anthropic.claude-opus-4-7), structured output fails with:

BedrockException - {"message":"The model returned the following errors: output_config.format: Extra inputs are not permitted"}

Root Cause

AmazonConverseConfig._supports_native_structured_outputs() returns True for Anthropic models because they have supports_native_structured_output=True in model_prices_and_context_window.json. This flag is correct for the native Anthropic Messages API, but not for Bedrock Converse.

When True, the Converse path generates outputConfig.textFormat. Bedrock internally translates this to output_config.format (Anthropic InvokeModel format) before forwarding to the model — and the model rejects it.

Fix

Updated _supports_native_structured_outputs() to return False for Anthropic models (detected via get_bedrock_base_model() prefix check). These models now use the universally reliable tool-call fallback on Converse, matching the Invoke path behavior.

Files Changed

FileChange
litellm/llms/bedrock/chat/converse_transformation.pyAdded Anthropic guard in _supports_native_structured_outputs()
tests/test_litellm/llms/bedrock/chat/test_converse_transformation.pyUpdated 4 existing tests + added 1 new test

Test Details

  • Updated test_supports_native_structured_outputs — Moved Anthropic model assertions to "unsupported" section
  • Updated 3 native output tests — Swapped model to qwen.qwen3-235b-a22b-2507-v1:0 (a non-Anthropic model that supports native structured output)
  • Added test_anthropic_model_uses_tool_call_fallback_for_structured_output — Tests 4 Anthropic model variants (with/without region prefix) to verify they all use tool-call fallback on Converse

Screenshots / Proof of Fix

Test output showing all 26 structured-output-related tests passing:

tests/.../test_converse_transformation.py::test_anthropic_model_uses_tool_call_fallback_for_structured_output PASSED
tests/.../test_converse_transformation.py::test_supports_native_structured_outputs PASSED
tests/.../test_converse_transformation.py::test_translate_response_format_native_output_config PASSED
tests/.../test_converse_transformation.py::test_native_structured_output_no_fake_stream PASSED
tests/.../test_converse_transformation.py::test_transform_request_with_output_config PASSED
tests/.../test_converse_transformation.py::test_translate_response_format_fallback_tool_call PASSED
====================== 26 passed, 96 deselected in 0.80s ======================

Changed files

  • litellm/llms/bedrock/chat/converse_transformation.py (modified, +12/-3)
  • tests/test_litellm/llms/bedrock/chat/test_converse_transformation.py (modified, +86/-22)

Code Example

BedrockException - {"message":"The model returned the following errors: output_config.format: Extra inputs are not permitted"}

---

# export AWS_BEARER_TOKEN_BEDROCK=bedrock-api-key-<>

from litellm import responses
from pydantic import BaseModel


class TextResponse(BaseModel):
    text: str


response = responses(
    api_base="https://bedrock-runtime.eu-central-1.amazonaws.com/",
    model="bedrock/invoke/eu.anthropic.claude-opus-4-7", # Or any anthropic model
    input=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "why is the sky blue? format your response as json",
                }
            ],
        }
    ],
    text_format=TextResponse,
)

TextResponse.model_validate_json(response.output[0].content[0].text)

---
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

When using the responses api, structured output (JSON schema) does not work correctly:

  • On the Converse API for Anthropic models
BedrockException - {"message":"The model returned the following errors: output_config.format: Extra inputs are not permitted"}

It works correctly:

  • On the Converse API for Amazon Nova models
  • On the Invoke API for Amazon Nova and Anthropic models

Relates to https://github.com/BerriAI/litellm/issues/21208

Steps to Reproduce

# export AWS_BEARER_TOKEN_BEDROCK=bedrock-api-key-<>

from litellm import responses
from pydantic import BaseModel


class TextResponse(BaseModel):
    text: str


response = responses(
    api_base="https://bedrock-runtime.eu-central-1.amazonaws.com/",
    model="bedrock/invoke/eu.anthropic.claude-opus-4-7", # Or any anthropic model
    input=[
        {
            "role": "user",
            "content": [
                {
                    "type": "input_text",
                    "text": "why is the sky blue? format your response as json",
                }
            ],
        }
    ],
    text_format=TextResponse,
)

TextResponse.model_validate_json(response.output[0].content[0].text)

Relevant log output

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

v1.83.14

Twitter / LinkedIn details

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: Structured Output fails for Anthropic models on bedrock/converse [1 pull requests, 1 comments, 2 participants]