Skip to main content
POST
streamGenerateContent
Identical to generateContent, but returned as a stream — chunks are pushed as they’re generated, reducing time-to-first-token.

Request

Note the query parameter ?alt=sse — without it, the response is a JSON array (one complete candidate per item); only with alt=sse do you get a standard SSE stream (the data: {...} form).

Stream chunks

The last chunk usually carries finishReason and usageMetadata.

Python (google-genai)

Notes

  • Streaming responses also support tools / function calling / thinking mode — those fields appear within some chunk.
  • The client must handle retries after an SSE disconnect (it is not idempotent — a retry is billed again).