gpt-image-2 text-to-image API reference and live testing — any valid resolution (incl. 4K), token-billed
Bearer sk-xxx), enter a prompt, choose size / quality, and send.| Param | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Fixed: gpt-image-2 |
prompt | string | Yes | — | Prompt, supports both Chinese and English |
size | string | No | auto | Output size — preset or constraint-satisfying custom |
quality | string | No | auto | low / medium / high / auto |
output_format | string | No | png | png / jpeg / webp |
output_compression | int | No | — | 0–100, only for jpeg / webp |
background | string | No | auto | opaque / auto (not supported: transparent) |
moderation | string | No | auto | auto / low (low-strength moderation) |
n | int | No | 1 | Only 1 supported |
usage field reflects actual billed tokens for this call. Billing is the sum of input text + input image + output image tokens. Use the pricing table on the overview page to estimate cost.API Key obtained from APIYI Console
Model name, fixed as gpt-image-2
gpt-image-2 Prompt text. Supports both Chinese and English. Place scene description at the front for better adherence.
"Cyberpunk city at night, neon sign closeup, cinematic frame"
Output size. Presets: 1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 2048x1152 / 3840x2160 / 2160x3840. Also accepts any valid custom size (max edge ≤ 3840, both multiples of 16, ratio ≤ 3:1, total pixels 0.65–8.3MP).
"2048x1152"
Quality tier. low (sketches/batch), medium (daily), high (final/fine text), auto (default)
auto, low, medium, high Output format
png, jpeg, webp Output compression (0–100), only effective for jpeg/webp
0 <= x <= 10085
Background mode. auto (default) or opaque. Not supported: transparent
auto, opaque Moderation strength. auto (default) or low
auto, low Number of images. This model only supports 1
1