Skip to main content
POST
  • Official OpenAI gpt-image-2 model
  • 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
Note: gpt-image-2 does not support transparent backgrounds. Passing background: "transparent" will be silently downgraded to auto.

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-2
string
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:21
4K tier only supports 6 ratios: 16:9 / 9:16 / 2:1 / 1:2 / 21:9 / 9:21. Use 1K or 2K for all other ratios.
string
default:"1k"
Resolution tier
  • 1k — 1024-base, fast and cost-effective (default)
  • 2k — 2048-base, suitable for posters and high-definition needs
  • 4k — 3840-base, only supports the 6 ratios above; high quality can take >120s

Size Reference Table

string
default:"high"
Image quality
  • low — fast and economical, suitable for drafts/previews
  • medium — balanced speed and quality
  • high — maximum detail, default value (4K + high can take 120s+)
string
default:"png"
Output format
  • png — default
  • jpeg — 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 ~ 10
string[]
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.task
string
Model name used
string
Task status
  • queued — waiting to be processed
  • in_progress — processing
  • completed — successfully completed
  • failed — failed
integer
Task progress percentage (0-100)
integer
Task creation timestamp (Unix timestamp)