low, medium, high) and multiple resolution options. Two model variants are available: gpt-image-2 supports up to 4K resolution and 6 reference images; gpt-image-2-r supports up to 16 reference images at 1K resolution. Tasks are processed asynchronously — you’ll receive a task ID immediately and can poll for the result once generation is complete.
Base URL
Endpoint
Authentication
Include your API key as a Bearer token in theAuthorization header on every request:
Models
GPT Image 2 offers two variants with different billing models and capabilities.Request Parameters
string
required
The model to use for image generation.
gpt-image-2— billed by quality tier; supports up to 4K resolution and 6 reference images.gpt-image-2-r— billed by resolution; supports up to 1K resolution and 16 reference images.
string
required
A text description of the image you want to generate. Clear, descriptive prompts produce the best results. Example:
"A serene mountain lake at sunset, photorealistic".string
default:"low"
The quality tier for the generated image. Only applies to the
gpt-image-2 model — this parameter is ignored for gpt-image-2-r.string
default:"1:1"
The aspect ratio of the generated image. Required when you pass
resolution. If you pass size instead, this field is optional.Supported values: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 5:4, 4:5, 2:1, 1:2, 21:9, 9:21string
default:"1k"
The output resolution. You must also pass
ratio when using this parameter. If you provide both size and resolution, size takes priority.gpt-image-2-r supports 1K only. 4K is limited to 6 specific ratios because other combinations exceed the maximum total pixel count.string
An exact pixel dimension for the generated image, expressed as
{width}x{height}. When provided, size overrides both resolution and ratio.Common examples: 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, 2160x3840Size rules:- Maximum edge length: ≤ 3840 px
- Both edges must be multiples of 16 px
- Long-edge : short-edge ratio must not exceed 3:1
- Total pixels must be between 655,360 and 8,294,400
array
An array of reference image URLs used to guide the visual style of the generated image.
gpt-image-2: up to 6 reference imagesgpt-image-2-r: up to 16 reference images
Response Fields
string
The unique task ID for this generation job. Pass this value to the Query Image Task endpoint (
GET /v1/result/{id}) to check status and retrieve your image.string
The object type. Always
image.integer
Unix timestamp indicating when the task was created.
string
The model name used for this task.
string
The initial task status immediately after creation.
string or null
An error message describing what went wrong.
null on a successful create; only populated when status is failed.Code Example
Success Response
Failure Response
Image generation is processed asynchronously. The create endpoint returns a task
id immediately — use that ID with the Query Image Task endpoint (GET /v1/result/{id}) to check task status and retrieve your image URL when generation is complete.