Skip to main content
POST
Generate images

Authorizations

Authorization
string
header
required

A workspace API key in an Authorization: Bearer header. A missing header, a scheme other than Bearer, a key of the wrong shape, and a key we reject are all 401.

Body

application/json

Generate an image with an offering that publishes image_generations in endpoint_families. Accepted controls depend on the offering.

model
string
required

The exact provider-qualified ID from GET /v1/models.

Example:

"vertex-ai/gemini-3.1-flash-image"

prompt
string
required
Minimum string length: 1
Example:

"A small blue circle centered on a plain white background. No text."

n
integer

How many images to request. Vertex Gemini accepts only 1.

Required range: x >= 1
Example:

1

size
string

Vertex Gemini accepts 1024x1024, 2048x2048 or 4096x4096 when supported by the model. The verified example uses 1024x1024.

Example:

"1024x1024"

quality
string

Model-specific image quality. Omit it for the Vertex Gemini example.

Example:

"standard"

response_format
string

Vertex Gemini accepts b64_json. Other image offerings can support different formats.

Example:

"b64_json"

Response

The image list. Vertex Gemini returns base64 image data and reported token usage; image-output tokens and text tokens use their respective published customer rates. This JSON endpoint does not stream. Other offerings may publish per-image prices. A missing image or inconsistent required image-usage details is a failed response.

created
integer
required

Response creation time as Unix seconds.

data
object[]
required
usage
object

Gemini inference usage. Thinking is separate from completion_tokens: total_tokens includes prompt, visible completion and thinking. Modality counts are subsets of enclosing totals, not extra tokens. Missing details do not prove zero usage.