BerriAI/litellm · error · ValueError

Expected ResponsesAPIResponse, got {type(result)}

Error message

Expected ResponsesAPIResponse, got {type(result)}

What it means

Error "Expected ResponsesAPIResponse, got {type(result)}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.py:176

            system=system,
            temperature=temperature,
            thinking=thinking,
            tool_choice=tool_choice,
            tools=tools,
            top_k=top_k,
            top_p=top_p,
            output_format=output_format,
            extra_kwargs=kwargs,
        )

        result: Final = await litellm.aresponses(**responses_kwargs)

        if stream:
            wrapper: Final = AnthropicResponsesStreamWrapper(responses_stream=result, model=model)
            return wrapper.async_anthropic_sse_wrapper()

        if not isinstance(result, ResponsesAPIResponse):
            raise ValueError(f"Expected ResponsesAPIResponse, got {type(result)}")

        return _ADAPTER.translate_response(result)

    @staticmethod
    def anthropic_messages_handler(
        max_tokens: int,
        messages: list[dict],
        model: str,
        context_management: dict | None = None,
        metadata: dict | None = None,
        output_config: AnthropicOutputConfig | None = None,
        stop_sequences: list[str] | None = None,
        stream: bool | None = False,
        system: str | None = None,
        temperature: float | None = None,
        thinking: dict | None = None,
        tool_choice: dict | None = None,
        tools: list[AllAnthropicToolsValues | dict] | None = None,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the upstream adapter; it returned an unexpected type instead of ResponsesAPIResponse.
  2. Upgrade litellm; the adapter contract may have changed.

When it happens

Trigger: Thrown at litellm/llms/anthropic/experimental_pass_through/responses_adapters/handler.py:176 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/3abe17c562058900. Report an issue: GitHub.