BerriAI/litellm · error · ValueError

Failed to translate request to OpenAI format

Error message

Failed to translate request to OpenAI format

What it means

Error "Failed to translate request to OpenAI format" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/handler.py:493

            request_data["output_format"] = output_format

        # Extract output_config from extra_kwargs so the translator can use it
        # (e.g. output_config.effort for adaptive thinking → reasoning_effort,
        # output_config.format → response_format for structured outputs).
        # Use explicit None check rather than `or {}` so an explicit empty dict
        # caller-passed argument is preserved (matters for tests that drive
        # the fallback inference path).
        extra_kwargs = extra_kwargs if extra_kwargs is not None else {}
        if "output_config" in extra_kwargs:
            request_data["output_config"] = extra_kwargs["output_config"]

        (
            openai_request,
            tool_name_mapping,
        ) = ANTHROPIC_ADAPTER.translate_completion_input_params_with_tool_mapping(request_data)

        if openai_request is None:
            raise ValueError("Failed to translate request to OpenAI format")

        completion_kwargs: Final[_CompletionKwargs] = {**openai_request}

        if stream:
            completion_kwargs["stream"] = stream
            completion_kwargs["stream_options"] = {
                "include_usage": True,
            }

        # Keys that must NOT be forwarded as raw extras into the OpenAI-format
        # ``completion_kwargs`` after translation. The translator above has
        # already consumed the meaningful parts of these inputs (e.g.
        # ``output_config.format`` → ``response_format``, ``output_config.effort``
        # → ``reasoning_effort`` for non-Claude targets). Re-adding the raw
        # Anthropic-shaped key here causes 400 "Extra inputs are not permitted"
        # on non-Anthropic backends (Azure OpenAI, Fireworks, Bedrock Nova,
        # etc.) and is silently lossy on Anthropic-family targets, which would
        # see the translated key ``response_format`` AND a duplicate, conflicting

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Check the Anthropic request payload for fields that cannot be translated to OpenAI format.

When it happens

Trigger: Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/handler.py:493 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/6bac31bb9ca3362f. Report an issue: GitHub.