Prefer asynchronous jobs
UsePOST /v1/images/generations/jobs for new integrations. It returns a task ID immediately and lets the client poll until the image is ready.
Text-to-image
gpt-image-2, gpt-image-2-2K, and gpt-image-2-4K support synchronous and asynchronous generation. The higher-resolution variants require dimensions that match the model limits and should normally use the asynchronous endpoint.
Reference images
Use public image URLs or Base64 input in the asynchronous JSON request:image field accepts one URL or an array. images is also accepted for compatible clients. Do not send image, image[], and images in the same request.
For Base64 input, use a complete data URL when possible:
Polling
- Create the job and save its
id. - Poll
GET /v1/images/generations/jobs/{job_id}every two to three seconds for the first 30 seconds. - Slow polling to five to ten seconds for longer jobs.
- Stop only at
succeededorfailed. - Read
dataon success anderror.messageon failure.
Size and quality
Usesize for the requested dimensions and quality for the model quality tier. The 2K and 4K variants validate width, height, aspect ratio, and pixel count more strictly than the base model. Follow the model limits shown in the API response and keep the original error body when diagnosing a rejected request.