Quick Answer
- Supports prompt-based image generation for marketing, e-commerce, and creative workloads.
- Supports reference_images (up to 5) for image-to-image and style control.
- Supports mask_url for local inpainting and targeted edits.
Key Parameters
- model | string | required | gpt-4o-image | - | Exact model identifier from ToAPIs.
- prompt | string | required | - | - | Primary image instruction prompt.
- size | string | optional | 1:1 | 1:1 | 2:3 | 3:2 | Output aspect ratio.
- n | integer | optional | 1 | 1-4 | Number of images to generate per request.
- reference_images | file[] | optional | - | max 5 | Reference image array for image-to-image and style control.
- mask_url | string | optional | - | - | Mask image URL for local edits/inpainting.
Common Errors
- 400 invalid_request_error: trigger=Missing fields, invalid types, or out-of-range values.; fix=Validate model/prompt/size/n/reference_images/mask_url fields.; retry=Retry after fixing payload.
- 401 authentication_error: trigger=Missing or invalid API key.; fix=Verify Authorization header and key scope.; retry=Retry after authentication is fixed.
- 429 rate_limit_exceeded: trigger=Request rate, concurrency, or current quota hits upstream rate limiting.; fix=Apply exponential backoff first, then review request rate, concurrency, and quota usage.; retry=Use 1s/2s/4s backoff with jitter; if it persists, reduce submission pressure.


