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
- Official OpenAI
gpt-image-2model - 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
string
required
All endpoints require Bearer Token authenticationGet your API Key from the API Key Management PageAdd to request header:
Body
string
default:"gpt-image-2"
required
Image generation model nameUse
gpt-image-2string
required
Text prompt describing the image to generateSupports English and Chinese; detailed descriptions of scene, style, and composition are recommended
string
default:"1:1"
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:21string
default:"1k"
Resolution 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
string
default:"high"
Image quality
low— fast and economical, suitable for drafts/previewsmedium— balanced speed and qualityhigh— maximum detail, default value (4K + high can take 120s+)
string
default:"png"
Output format
png— defaultjpeg— smaller file size (supports compression)
Azure OpenAI does not support
webp format.integer
default:100
JPEG compression level, range
0–100 (0 = no compression, 100 = maximum compression, default 100)Only applies when output_format is "jpeg"integer
default:1
Number of images to generateRange:
1 ~ 10string[]
Reference 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
string
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
string
Unique task identifier for status queries
string
Object type, always
generation.taskstring
Model name used
string
Task status
queued— waiting to be processedin_progress— processingcompleted— successfully completedfailed— failed
integer
Task progress percentage (0-100)
integer
Task creation timestamp (Unix timestamp)