mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
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.
This commit is contained in:
parent
ea8ac80961
commit
fd2f476d05
1 changed files with 19 additions and 0 deletions
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue