GPT-Image-2
GPT-Image-2 Official Channel Image Generation
Generate images with the official OpenAI gpt-image-2 model — text-to-image, image-to-image, and inpainting (mask) in one API, with 1K / 2K / 4K resolution tiers
POST
Documentation Index
Fetch the complete documentation index at: https://docs.toapis.com/llms.txt
Use this file to discover all available pages before exploring further.
- Official OpenAI
gpt-image-2model, called via thegpt-image-1.5-officialmodel name - Async processing — returns a task ID for subsequent polling
- Supports text-to-image, multi-reference image-to-image, and mask-based inpainting
- 13 aspect ratios with 1K / 2K / 4K resolution tiers
- Up to 4 images per request, up to 16 reference images
Authorizations
All endpoints require Bearer Token authenticationGet your API Key from the API Key Management PageAdd to request header:
Body
Image generation model nameUse
gpt-image-1.5-officialText prompt describing the image to generateSupports English and Chinese; detailed descriptions of scene, style, and composition are recommended
Aspect ratioSupported values, or pass
auto to let the server choose:1:1 · 3:2 · 2:3 · 4:3 · 3:4 · 5:4 · 4:5 · 16:9 · 9:16 · 2:1 · 1:2 · 21:9 · 9:21Resolution tier
1k— 1024-base, fast and cost-effective (default)2k— 2048-base, suitable for posters and high-definition needs4k— 3840-base, only supports the 6 ratios above;highquality can take >120s
Size Reference Table
| size | 1K | 2K | 4K |
|---|---|---|---|
1:1 | 1024x1024 | 2048x2048 | Not supported |
3:2 | 1536x1024 | 2048x1360 | Not supported |
2:3 | 1024x1536 | 1360x2048 | Not supported |
4:3 | 1024x768 | 2048x1536 | Not supported |
3:4 | 768x1024 | 1536x2048 | Not supported |
5:4 | 1280x1024 | 2560x2048 | Not supported |
4:5 | 1024x1280 | 2048x2560 | Not supported |
16:9 | 1536x864 | 2048x1152 | 3840x2160 |
9:16 | 864x1536 | 1152x2048 | 2160x3840 |
2:1 | 2048x1024 | 2688x1344 | 3840x1920 |
1:2 | 1024x2048 | 1344x2688 | 1920x3840 |
21:9 | 2016x864 | 2688x1152 | 3840x1648 |
9:21 | 864x2016 | 1152x2688 | 1648x3840 |
Image quality
low— fast and economical, suitable for drafts/previewsmedium— balanced speed and qualityhigh— maximum detail, default value (4K + high can take 120s+)
Output format
png— defaultjpeg— smaller file size (supports compression)
Azure OpenAI does not support
webp format.JPEG compression level, range
0–100 (0 = no compression, 100 = maximum compression, default 100)Only applies when output_format is "jpeg"Number of images to generateRange:
1 ~ 10Reference image URL array for image-to-image generation
- Maximum 16 images, must be publicly accessible stable URLs
- Use the Upload Image API to upload local files and get URLs
Mask image URL for inpaintingMust be used together with
image_urls. The mask must match the dimensions of the first reference image and include an Alpha channel (transparent areas indicate regions to be repainted)Response
Unique task identifier for status queries
Object type, always
generation.taskModel name used
Task status
queued— waiting to be processedin_progress— processingcompleted— successfully completedfailed— failed
Task progress percentage (0-100)
Task creation timestamp (Unix timestamp)