BerriAI/litellm · error · ValueError

Failed to transform response to Anthropic format

Error message

Failed to transform response to Anthropic format

What it means

Error "Failed to transform response to Anthropic format" thrown in BerriAI/litellm.

Source

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

            transformed_stream: Final = ANTHROPIC_ADAPTER.translate_completion_output_params_streaming(
                completion_response,
                model=model,
                tool_name_mapping=tool_name_mapping,
                polyfill_result=polyfill_result,
                is_async=True,
            )
            if transformed_stream is not None:
                return transformed_stream
            raise ValueError("Failed to transform streaming response")
        else:
            anthropic_response: Final = ANTHROPIC_ADAPTER.translate_completion_output_params(
                cast(ModelResponse, completion_response),
                tool_name_mapping=tool_name_mapping,
                polyfill_result=polyfill_result,
            )
            if anthropic_response is not None:
                return anthropic_response
            raise ValueError("Failed to transform response to Anthropic format")

    @staticmethod
    def anthropic_messages_handler(
        max_tokens: int,
        messages: _AnthropicMessages,
        model: str,
        metadata: dict[str, object] | None = None,
        stop_sequences: list[str] | None = None,
        stream: bool | None = False,
        system: str | None = None,
        temperature: float | None = None,
        thinking: dict[str, object] | None = None,
        tool_choice: dict[str, object] | None = None,
        tools: list[dict[str, object]] | None = None,
        top_k: int | None = None,
        top_p: float | None = None,
        output_format: dict[str, object] | None = None,
        _is_async: bool = False,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Check the upstream response format; see logs for details.

When it happens

Trigger: Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/handler.py:627 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/d3bd0f4705dcdba5. Report an issue: GitHub.