streamGenerateContent endpoint. The endpoint delivers Server-Sent Events (SSE), allowing your application to process response chunks as they arrive.
Key capabilities
- SSE streaming — Receive
GenerateContentResponsechunks as they are generated. - Text-to-image — Generate images from text prompts.
- Image editing — Include a reference image and an editing instruction in the same request.
- Image settings — Set output aspect ratio and resolution with
imageConfig.
SSE response format
The endpoint returns SSE events. Eachdata: line contains a JSON GenerateContentResponse chunk. Read candidates[].content.parts[] from each chunk; a part can contain text or image data. Image data uses inlineData with a MIME type and Base64-encoded data. A chunk may also contain usage metadata. The number and ordering of chunks can vary by response.
Request fields use the native Gemini API format. In a streaming response, generated image bytes are returned in
inlineData.data using Base64 encoding.Text-to-image example
Image editing example
Send the editing instruction and the reference image in the sameparts array. The request uses inlineData with Base64 image bytes.
cURL
Parameters
API Reference
View the streaming request and response schema for Gemini Nano Banana 2.1.