BerriAI/litellm · error · VertexAgentEngineError

str(response.read())

Error message

str(response.read())

What it means

Vertex Agent Engine sync streaming guard: the streaming POST returned a status other than 200, so VertexAIError is raised with the status code and the fully-read response body before the stream is consumed.

Solutions

  1. Inspect the raw response content read from the stream for the error detail.
  2. Verify Agent Engine endpoint configuration and credentials.

Example fix

# print the raw response body from the raised error.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Triggered when the Vertex Agent Engine sync response indicates an error; the response body is surfaced.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at litellm/llms/vertex_ai/agent_engine/transformation.py:391

        from litellm.utils import CustomStreamWrapper

        if client is None or not isinstance(client, HTTPHandler):
            client = _get_httpx_client(params={})

        # Avoid logging sensitive api_base directly
        verbose_logger.debug("Making sync streaming request to Vertex AI endpoint.")

        # Make streaming request
        response: Final = client.post(
            api_base,
            headers=headers,
            data=json.dumps(data),
            stream=True,
            logging_obj=logging_obj,
        )

        if response.status_code != 200:
            raise VertexAgentEngineError(status_code=response.status_code, message=str(response.read()))

        # Create iterator for SSE stream
        completion_stream: Final = self.get_streaming_response(model=model, raw_response=response)

        streaming_response: Final = CustomStreamWrapper(
            completion_stream=completion_stream,
            model=model,
            custom_llm_provider=custom_llm_provider,
            logging_obj=logging_obj,
        )

        # LOGGING
        logging_obj.post_call(
            input=messages,
            api_key="",
            original_response="first stream response received",
            additional_args={"complete_input_dict": data},
        )

View on GitHub (pinned to 77b7c6c40c)