Skip to main content
Gemini Nano Banana 2.1 can return generated content through the native Gemini streamGenerateContent endpoint. The endpoint delivers Server-Sent Events (SSE), allowing your application to process response chunks as they arrive.

Key capabilities

  • SSE streaming — Receive GenerateContentResponse chunks 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. Each data: 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 same parts 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.

Official references