GPT-Image-2
GPT-Image-2 Official Channel Image Generation
- OpenAI official
gpt-image-2model, based on/v1/images/generationscompatible protocol - Asynchronous processing, returns
task_idfor subsequent queries - Text-to-image / image-to-image / inpainting (mask) — all-in-one
- New
resolutiontier field — 1K / 2K / 4K selection - 15 aspect ratios supported across the 1K / 2K / 4K tiers
- Up to 4 images per request, up to 16 reference images
- 95% parameter alignment with
gpt-image-1.5-official— migration only requires changing the model name
POST
Documentation Index
Fetch the complete documentation index at: https://gccai.heqingsong.uk/llms.txt
Use this file to discover all available pages before exploring further.
Authorizations
All endpoints require Bearer Token authenticationGet your API Key:Visit the API Key management page to get your API KeyInclude it in the request header:
Body
Image generation model nameFixed to
gpt-image-2-official (OpenAI official gpt-image-2 model)Text description for image generation
- Supports English and Chinese, detailed descriptions recommended
- Pre-submission content moderation / safety review — violations are rejected immediately
Image aspect ratioExternally uses ratio values; internally mapped to actual pixels according to
resolution.Supported ratios, plus auto to let the server pick a suitable ratio automatically:auto- Automatic (server picks a ratio based on prompt / reference images)1:1- Square (default, social avatars / logos)3:2- Landscape (common DSLR ratio)2:3- Portrait (vertical posters)4:3- Landscape (classic monitor / slideshow)3:4- Portrait5:4- Landscape4:5- Portrait (Instagram vertical post)16:9- Landscape (widescreen video thumbnail)9:16- Portrait (phone full-screen / short video cover)2:1- Landscape (web banner)1:2- Portrait3:1- Landscape (ultra-wide banner)1:3- Portrait (extra-tall poster)21:9- Landscape (cinematic ultra-wide)9:21- Portrait
1881x836 / 887x1774.Resolution tier (new field)Controls the actual output clarity.
1k- 1024 baseline, cost-efficient for daily use (default)2k- 2048 baseline, suitable for posters / high-definition needs4k- 3840 baseline, supports the 15 ratios in the mapping table below
Image quality
auto- Automatic (default, typically equivalent tolow)low- Fast and economical, sufficient for rough outlinesmedium- Balancedhigh- Maximum precision (4K + high can take >120s)
Background mode
auto- Automatic (default)opaque- Opaquetransparent- ⚠️ gpt-image-2-official does not support transparent backgrounds; the system silently downgrades toauto
Moderation strength
auto- Default moderation strengthlow- More lenient moderation
Output format
png- Defaultjpeg- Smaller fileswebp- Optimal for modern browsers
Output compression level, range
0-100- Only effective for
jpeg/webp
Number of images to generateRange:
1 ~ 4Reference image URL array
Mask image URL, used for inpainting
- Must be used together with
image_urls
Size × Resolution Mapping
size × resolution → OpenAI actual pixels (15 ratios × 3 tiers):
| size | 1k | 2k | 4k |
|---|---|---|---|
1:1 | 1024×1024 | 2048×2048 | 2880×2880 |
3:2 | 1536×1024 | 2048×1360 | 3520×2336 |
2:3 | 1024×1536 | 1360×2048 | 2336×3520 |
4:3 | 1024×768 | 2048×1536 | 3312×2480 |
3:4 | 768×1024 | 1536×2048 | 2480×3312 |
5:4 | 1280×1024 | 2560×2048 | 3216×2576 |
4:5 | 1024×1280 | 2048×2560 | 2576×3216 |
16:9 | 1536×864 | 2048×1152 | 3840×2160 |
9:16 | 864×1536 | 1152×2048 | 2160×3840 |
2:1 | 2048×1024 | 2688×1344 | 3840×1920 |
1:2 | 1024×2048 | 1344×2688 | 1920×3840 |
3:1 | 1881×836 / 1536×512 | 3072×1024 | 3840×1280 |
1:3 | 887×1774 / 512×1536 | 1024×3072 | 1280×3840 |
21:9 | 2016×864 | 2688×1152 | 3840×1648 |
9:21 | 864×2016 | 1152×2688 | 1648×3840 |
Note: Some dimensions are approximated based on multiples of 16 and pixel limits, such as3:2/2:3@ 2K being 2048×1360 and21:9@ 4K being 3840×1648. Use the actual pixels in the table as the source of truth.
Usage Examples
Text-to-image (minimal request)Response
Response status code
Response data array
Querying Task Results
After successful submission, atask_id is returned. Poll the task status via GET /v1/tasks/{task_id}, see Task Query API for details.
Success Response Example
submitted → in_progress → completed / failed.
Image access: data.result.images[0].url[0].
Polling Recommendations
- Initial query delay: Wait 10~20 seconds after submission before first query
- Query interval: 3~5 seconds recommended
- Timeout reference:
high + 2k/4kcombinations can take up to 130 seconds; client timeout ≥ 180 seconds recommended - Batch query: To query multiple tasks at once, use
POST /v1/tasks/batch