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
string
required
Must be set to
gpt-image-2.string
Generation prompt. For text-to-image semantics, this should be treated as required.
integer
Number of images to generate. If omitted or explicitly set to
0, the unified layer falls back to 1.string
Output size. Common base tiers are
1024x1024、1536x1152、1536x1024、1024x1536、1920x1080、1080x1920.string | array<string> | object
Optional reference image input. Commonly written as a Base64 string or Base64 array, suitable for channels that require image style reference.
string
Response format. Common values are
url and b64_json.string
Quality field. Whether it actually takes effect depends on the final matched channel.
string | object
Style field, passed through as-is to supported upstreams.
string | object
Background control field, passed through as-is to supported upstreams.
boolean
Explicit watermark switch.
false and omission have different semantics.Base Ratios and Size Tiers
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
integer
Generation timestamp.
string
The image URL returned when
response_format = url.string
The Base64 image data returned when
response_format = b64_json.string
Some upstreams rewrite the prompt and return it in this field.