Gemini 2.5 Flash Image (Stream) generates images using Google’s Gemini 2.5 Flash Image model through the native Gemini API via Anyfast. Responses are delivered in real-time using Server-Sent Events (SSE), with thinking chunks arriving first followed by the image data chunk.Documentation Index
Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
Use this file to discover all available pages before exploring further.
Key capabilities
- SSE Streaming — Real-time delivery of thinking and image chunks
- Thinking mode — Internal reasoning chunks (
thought: true) stream before the final image - Text-to-image — Generate images from text descriptions
- Image editing — Pass a reference image in
inline_dataalongside your text instruction - Aspect ratio control —
1:1,4:3,3:4,16:9,9:16 - Resolution control —
1K(~1024px),2K(~2048px),4K(~4096px) on the long edge
SSE response format
The streaming endpoint returns newline-delimited SSE lines. Each line starts withdata: followed by a JSON object. There are three chunk types:
- Thinking chunks — Arrive first;
parts[0].thoughtistrue - Image chunk — Contains
parts[0].inlineDatawithmimeTypeand base64data(note: camelCase in stream response) - Final usage chunk — Contains top-level
usageMetadatawiththoughtsTokenCountand token details
In the streaming response, the image field is named
inlineData (camelCase). In the non-streaming request body, the field is inline_data (snake_case). This is a native Gemini API behaviour.Text-to-image example
Image editing example (with reference image)
Include both atext instruction and an inline_data reference image in the same parts array.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
key | string | Yes | API key (query parameter) |
alt | string | No | Set to sse for explicit SSE mode (optional, streaming is default) |
contents[].parts[].text | string | Yes | Text prompt or instruction |
contents[].parts[].inline_data.mime_type | string | No | Reference image type: image/jpeg, image/png, image/webp |
contents[].parts[].inline_data.data | string | No | Base64-encoded reference image |
generationConfig.responseModalities | array | Yes | ["IMAGE"] or ["TEXT", "IMAGE"] |
generationConfig.imageConfig.aspectRatio | string | No | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 |
generationConfig.imageConfig.imageSize | string | No | 1K / 2K / 4K (default: 1K) |
API Reference
View the interactive API playground for Gemini 2.5 Flash Image (Stream).