gpt-image-2 Image Generation API
gpt-image-2
gpt-image-2 Image Generation API
Use POST /v1/images/generations to call the unified image generation entry for gpt-image-2.
POST
gpt-image-2 Image Generation API
gpt-image-2 Image Generation API
gpt-image-2 uses a unified image generation entry, suitable for text-to-image requests based on standard ratios and size tiers.
- The unified entry is
POST /v1/images/generations. - Select the target model by setting
model = "gpt-image-2". - Supports both
urlandb64_jsonresponse formats. - You can include
imagein JSON as a reference image; whether it takes effect depends on the actual image channel that is matched. - If
nis omitted or explicitly set to0, the unified layer falls back to1.
Method and Path
Request Example
Response Example
Authentication
Body
Must be set to
gpt-image-2.Generation prompt. For text-to-image semantics, this should be treated as required.
Number of images to generate. If omitted or explicitly set to
0, the unified layer falls back to 1.Output size. Common base tiers are
1024x1024、1536x1152、1536x1024、1024x1536、1920x1080、1080x1920.Optional reference image input. Commonly written as a Base64 string or Base64 array, suitable for channels that require image style reference.
Response format. Common values are
url and b64_json.Quality field. Whether it actually takes effect depends on the final matched channel.
Style field, passed through as-is to supported upstreams.
Background control field, passed through as-is to supported upstreams.
Explicit watermark switch.
false and omission have different semantics.Base Ratios and Size Tiers
| Preset | Actual Target Size |
|---|---|
1:1 | 1024x1024 |
4:3 | 1536x1152 |
3:2 | 1536x1024 |
2:3 | 1024x1536 |
16:9 | 1920x1080 |
9:16 | 1080x1920 |
If the actual channel does not natively accept the target size, the gateway or plugin will fall back to a closer official size and append the ratio intent to the prompt.
Response
Generation timestamp.
The image URL returned when
response_format = url.The Base64 image data returned when
response_format = b64_json.Some upstreams rewrite the prompt and return it in this field.