BerriAI/litellm · error · Exception

The response was blocked by VertexAI. {vertex_chunk}

Error message

The response was blocked by VertexAI. {vertex_chunk}

What it means

Vertex AI streaming guard: the stream contains a block signaling Vertex blocked the response (safety/policy filtering); instead of returning empty content, the chunk is surfaced as an exception with the raw payload so callers know generation was suppressed.

Source

Thrown at litellm/litellm_core_utils/streaming_handler.py:1347

                                        },
                                        "type": "function",
                                    }
                                ],
                            )
                            _streaming_response: Final = StreamingChoices(delta=_delta_obj)
                            _model_response: Final = ModelResponseStream()
                            _model_response.choices = [_streaming_response]
                            response_obj = {"original_chunk": _model_response}
                        else:
                            raise original_exception
                    if (
                        hasattr(vertex_chunk.candidates[0], "finish_reason")
                        and vertex_chunk.candidates[0].finish_reason.name != "FINISH_REASON_UNSPECIFIED"
                    ):  # every non-final chunk in vertex ai has this
                        self.received_finish_reason = map_finish_reason(vertex_chunk.candidates[0].finish_reason.name)
                except Exception:
                    if vertex_chunk.candidates[0].finish_reason.name == "SAFETY":
                        raise Exception(f"The response was blocked by VertexAI. {vertex_chunk}")
            else:
                completion_obj["content"] = str(vertex_chunk)
        elif self.custom_llm_provider == "petals":
            if self.completion_stream is None or len(self.completion_stream) == 0:
                if self.received_finish_reason is not None:
                    raise StopIteration
                else:
                    self.received_finish_reason = "stop"
            chunk_size = 30
            stream = cast(Any, self.completion_stream)
            new_chunk = stream[:chunk_size]
            completion_obj["content"] = new_chunk
            self.completion_stream = stream[chunk_size:]
        elif self.custom_llm_provider == "palm":
            # fake streaming
            response_obj = {}
            if self.completion_stream is None or len(self.completion_stream) == 0:
                if self.received_finish_reason is not None:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. VertexAI safety filters blocked the response; revise the prompt or adjust safety settings.
  2. Inspect vertex_chunk for the block reason.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at litellm/litellm_core_utils/streaming_handler.py:1347 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/dce2876a2e93c13e. Report an issue: GitHub.