Classic text to image via gpt image 1. Reliable AI art generation for any prompt, from simple to complex.
Response Example
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
model | string | ✅ Yes | gpt-image-1 | gpt-image-1gpt-image-1-minigpt-image-1.5gpt-image-2 | The model to use for image generation. Defaults to gpt-image-1. |
prompt | string | ✅ Yes | - | - | A text description of the desired image(s). The maximum length is 32000 characters. |
n | integer | ❌ No | 1 | 1-10 | The number of images to generate. Must be between 1 and 10. |
size | string | ❌ No | auto | auto1024x10241536x10241024x15362048x20482048x11523840x21602160x3840or any valid custom size | The size of the generated images. For gpt-image-1: one of auto, 1024x1024, 1536x1024, or 1024x1536. For gpt-image-2: supports arbitrary resolutions (max edge ≤ 3840px, both sides must be multiples of 16px, aspect ratio ≤ 3:1, total pixels between 655,360 and 8,294,400). Outputs exceeding 2560×1440 are considered experimental. |
quality | string | ❌ No | auto | autohighmediumlow | The quality of the generated images. One of auto, low, medium, or high. Defaults to auto. Not supported by -plus suffixed models. |
background | string | ❌ No | auto | opaqueautotransparent | Allows to set transparency for the background of the generated image(s). transparent is only supported by gpt-image-1 (not gpt-image-2) and requires output_format to be png or webp. When auto is used, the model will automatically determine the best background. |
moderation | string | ❌ No | auto | lowauto | Content moderation level for generated images. low is less restrictive, auto is the default. |
output_format | string | ❌ No | auto | autopngjpegwebp | The output format of the generated image(s). Defaults to auto. jpeg is faster than png for latency-sensitive scenarios. |
output_compression | integer | ❌ No | 100 | 0-100 | The compression level (0-100%) for the output image. Only applicable with webp or jpeg format. Defaults to 100. |
stream | boolean | ❌ No | false | truefalse | Whether to stream the response in real-time. When enabled, partial images can be received during generation. |
partial_images | integer | ❌ No | - | 0-3 | The number of partial images to receive during streaming. Only used when stream is true. Each partial image incurs an additional 100 image output tokens. |
user | string | ❌ No | - | - | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. |
| Error Code | Error Name | Description |
|---|---|---|
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn’t have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You’ve exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |