BerriAI/litellm · error · VertexAIError

{error_status} - {error_message}

Error message

{error_status} - {error_message}

What it means

Gemini streaming error detector: the chunk embeds a structured provider error (e.g. 429 RESOURCE_EXHAUSTED) rather than a valid candidate; it is re-raised as VertexAIError with the provider's status code and message.

Source

Thrown at litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py:3118

        """Detect embedded errors (e.g. 429 RESOURCE_EXHAUSTED) in streaming chunks and raise VertexAIError."""
        if "error" not in chunk:
            return
        error_data: Final = chunk["error"]
        if not isinstance(error_data, dict):
            raise VertexAIError(
                status_code=500,
                message=f"Unexpected error format in mid-stream chunk: {error_data}",
            )
        raw_code = error_data.get("code", 500)
        if raw_code is None:
            raw_code = 500
        try:
            error_code = int(raw_code)
        except (TypeError, ValueError):
            error_code = 500
        error_message: Final = error_data.get("message", "Unknown error")
        error_status: Final = error_data.get("status", "UNKNOWN")
        raise VertexAIError(
            status_code=error_code,
            message=f"{error_status} - {error_message}",
        )

    def _apply_stream_candidates(
        self,
        _candidates: list[Candidates],
        model_response: "ModelResponseStream",
    ) -> tuple[list[dict], list[dict], list[dict], list[dict]]:
        (
            grounding_metadata,
            url_context_metadata,
            safety_ratings,
            citation_metadata,
            self.cumulative_tool_call_index,
        ) = VertexGeminiConfig._process_candidates(
            _candidates,
            model_response,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Read error_status and error_message for the specific failure.
  2. Fix per the returned status (auth, quota, invalid request).

Example fix

# handle based on the error_status shown in the exception.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Triggered when a streaming chunk from Vertex AI Gemini carries an error status and message.

Common situations: See trigger scenarios.


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