BerriAI/litellm · error · ValueError

Failed to transform streaming response

Error message

Failed to transform streaming response

What it means

The Google GenAI adapter tried to convert a streaming completion into generate_content format but translate_completion_output_params_streaming returned None, i.e. the stream could not be transformed — a mismatch between the adapter and the actual stream shape.

Solutions

  1. Retry the request; a streaming chunk failed transformation.
  2. Enable verbose logging to inspect the failing chunk and update litellm if it is a known provider format change.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/google_genai/adapters/handler.py:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/71a7e1ebd1773ad0. Report an issue: GitHub.

Appendix: source

Thrown at litellm/google_genai/adapters/handler.py:93

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

            if stream:
                # Check if completion_response is actually a stream or a ModelResponse
                # This can happen in error cases or when stream is not properly supported
                if not hasattr(completion_response, "__aiter__"):
                    # If it's not a stream, treat it as a regular response
                    generate_content_response = GOOGLE_GENAI_ADAPTER.translate_completion_to_generate_content(
                        cast(ModelResponse, completion_response)
                    )
                    return generate_content_response
                else:
                    # Transform streaming completion response to generate_content format
                    transformed_stream: Final = GOOGLE_GENAI_ADAPTER.translate_completion_output_params_streaming(
                        completion_response
                    )
                    if transformed_stream is not None:
                        return transformed_stream
                    raise ValueError("Failed to transform streaming response")
            else:
                # Transform completion response back to generate_content format
                generate_content_response = GOOGLE_GENAI_ADAPTER.translate_completion_to_generate_content(
                    cast(ModelResponse, completion_response)
                )
                return generate_content_response

        except Exception as e:
            raise ValueError(f"Error calling litellm.acompletion for generate_content: {e}")

    @staticmethod
    def generate_content_handler(
        model: str,
        contents: list[dict[str, object]] | dict[str, object],
        litellm_params: GenericLiteLLMParams,
        config: dict[str, object] | None = None,
        stream: bool = False,
        _is_async: bool = False,

View on GitHub (pinned to 77b7c6c40c)