BerriAI/litellm · error · ValueError

Failed to transform streaming response

Error message

Failed to transform streaming response

What it means

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

Source

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

            top_k=top_k,
            top_p=top_p,
            output_format=output_format,
            extra_kwargs=kwargs,
        )

        completion_response: Final = await litellm.acompletion(**completion_kwargs)

        if stream:
            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,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Check the upstream stream format; see logs for the failing chunk.

When it happens

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