GPT-Image-2
GPT-Image-2 Official Channel 画像生成
Generate images with the official OpenAI gpt-image-2-official model — text-to-image, image-to-image, and inpainting (mask) in one API, with 1K / 2K / 4K resolution tiers
POST
- Official OpenAI
gpt-image-2-officialmodel - 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
必須
All endpoints require Bearer Token authenticationGet your API Key from the API Key Management PageAdd to request header:
Body
string
デフォルト:"gpt-image-2-official"
必須
Image generation model nameUse
gpt-image-2-officialstring
必須
Text prompt describing the image to generateSupports English and Chinese; detailed descriptions of scene, style, and composition are recommended
string
デフォルト:"1:1"
Aspect ratioPreset values, or pass
auto to let the upstream provider 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:21You may also pass any ratio in width:height format, such as 1:3 or 7:4, subject to the custom-size limits below.With auto, the upstream provider determines the final aspect ratio and pixel dimensions, so a fixed output is not guaranteed.string
デフォルト:"1k"
Resolution tier
1k— 1024-base, fast and cost-effective (default)2k— 2048-base, suitable for posters and high-definition needs4k— 3840-base;highquality can take more than 120 seconds
Size Reference Table
Custom Resolutions
In addition to the presets above, pass any ratio inwidth:height format through size. The service calculates pixel dimensions from the selected resolution tier. The resulting dimensions must meet all of these limits:
- Both sides must be multiples of 16 pixels
- The long edge can be at most 3,840 pixels (4K)
- The aspect ratio can be at most 3:1
- Total pixel count must be between 655,360 and 8,294,400
size: "1:3"withresolution: "2k"→1024x3072size: "7:4"withresolution: "1k"→1344x768
string
デフォルト:"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
デフォルト:"png"
Output format
png— defaultjpeg— smaller file size (supports compression)
Azure OpenAI does not support
webp format.integer
デフォルト:100
JPEG compression level, range
0–100 (0 = no compression, 100 = maximum compression, default 100)Only applies when output_format is "jpeg"integer
デフォルト: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 画像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)レスポンス
string
Unique task identifier for status queries
string
Object type, always
generation.taskstring
モデル 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)