Skip to main content
POST
cURL

Query Parameters

key
string
required

API Key

alt
enum<string>

Set to sse for explicit Server-Sent Events mode (optional, streaming is the default behaviour of this endpoint)

Available options:
sse

Body

application/json
contents
object[]
required

Array of conversation turns. Each turn has a role and parts. A part can be a text prompt, or an inline_data image (base64). To use a reference image, include both a text part and an inline_data part in the same parts array.

Example:
generationConfig
object
required

Response

Streaming SSE response. Each line starts with "data:" followed by a JSON chunk. Three chunk types are delivered in order: (1) Thinking chunks — parts[0].thought is true; (2) Image chunk — parts[0].inlineData contains mimeType and base64 data (camelCase); (3) Final usage chunk — top-level usageMetadata with thoughtsTokenCount.

A single SSE chunk. Three variants are possible: thinking chunk (parts[].thought=true), image chunk (parts[].inlineData), or usage chunk (no candidates).

candidates
object[]

Present in thinking and image chunks; absent in the final usage chunk.

usageMetadata
object

Token usage. Final chunk contains full details including thoughtsTokenCount.

modelVersion
string
Example:

"gemini-2.5-flash-image"

createTime
string
Example:

"2025-01-01T00:00:00Z"

responseId
string
Example:

"abc123"