GPT Image 2 generates high-quality images from text prompts with flexible quality tiers (Documentation Index
Fetch the complete documentation index at: https://docs.xingchaoyiqing.com/llms.txt
Use this file to discover all available pages before exploring further.
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.| Model | Billing | Max Resolution | Max Reference Images |
|---|---|---|---|
gpt-image-2 | By quality tier | 4K | 6 |
gpt-image-2-r | By resolution | 1K | 16 |
Request Parameters
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.
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".The quality tier for the generated image. Only applies to the
gpt-image-2 model — this parameter is ignored for gpt-image-2-r.| Value | Description |
|---|---|
low | Fast generation, suitable for drafts and previews (default) |
medium | Balanced speed and quality, suitable for general use |
high | Maximum quality, suitable for final output and detail-rich scenes |
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:21The output resolution. You must also pass
ratio when using this parameter. If you provide both size and resolution, size takes priority.| Value | Supported Models | Notes |
|---|---|---|
1k | gpt-image-2, gpt-image-2-r | Default |
2k | gpt-image-2 only | — |
4k | gpt-image-2 only | Supported ratios: 16:9, 9:16, 2:1, 1:2, 21:9, 9:21 only |
gpt-image-2-r supports 1K only. 4K is limited to 6 specific ratios because other combinations exceed the maximum total pixel count.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
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
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.The object type. Always
image.Unix timestamp indicating when the task was created.
The model name used for this task.
The initial task status immediately after creation.
| Value | Meaning |
|---|---|
queued | Task is waiting in the queue |
processing | Task is actively being processed |
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.