From fd2f476d05dc3b53e20e24113236f3c346824933 Mon Sep 17 00:00:00 2001 From: Rob Sherman Date: Tue, 3 Mar 2026 17:33:36 -0800 Subject: [PATCH] fix(anthropic-adapter): strip output_config for non-Anthropic backends output_config is an Anthropic Claude-specific parameter that has no equivalent in other model providers. When routing through the experimental pass-through adapter to non-Anthropic backends (e.g. Amazon Nova Pro on Bedrock, Llama, Mistral), the parameter is forwarded verbatim and causes HTTP 400 "extraneous key" errors. Strip output_config from the request when the target provider is not an Anthropic Claude model. The thinking parameter is intentionally excluded from stripping because some non-Anthropic models (e.g. Qwen) support reasoning/thinking natively and the adapter already handles translation for those cases. --- .../adapters/handler.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py index 2ffedbf154d..26b627f62e6 100644 --- a/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/adapters/handler.py @@ -195,7 +195,26 @@ class LiteLLMMessagesToCompletionTransformationHandler: "include_usage": True, } + # These params are only understood by Anthropic Claude models. + # When routing to a non-Anthropic backend (e.g. Bedrock Nova Pro, + # Llama, Mistral), they are rejected as unknown fields. We strip + # them here so that the underlying model receives a clean request. + # Note: "thinking" is intentionally excluded from this list because + # some non-Anthropic models (e.g. Qwen) support reasoning/thinking + # and the existing adapter logic already handles translation for those. + _anthropic_only_params = {"output_config"} + _target_provider = (extra_kwargs or {}).get("custom_llm_provider", "") + _is_anthropic_claude = _target_provider in ( + "anthropic", + ) or ( + _target_provider == "bedrock" + and "anthropic.claude" in completion_kwargs.get("model", "") + ) + excluded_keys = {"anthropic_messages"} + if not _is_anthropic_claude: + excluded_keys = excluded_keys | _anthropic_only_params + extra_kwargs = extra_kwargs or {} for key, value in extra_kwargs.items(): if (