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`.

POSThttps://zx1.deepwl.net/v1/images/generations
Request
curl -X POST https://zx1.deepwl.net/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '
{
  "model": "gpt-image-2",
  "prompt": "A modern homepage illustration for an API platform, white background, teal-blue blocks, clean whitespace",
  "n": 1,
  "size": "1536x1024",
  "response_format": "url"
}'
Response
{
  "created": 1735689600,
  "data": [
    {
      "url": "https://.../images/img-abc123.png",
      "revised_prompt": "A modern homepage illustration for an API platform, white background, teal-blue blocks, clean whitespace"
    }
  ]
}

gpt-image-2 uses the unified image generation entry (POST /v1/images/generations), suitable for text-to-image requests based on standard ratios and size tiers.

  • Select the target model by setting model = "gpt-image-2".
  • Supports both url and b64_json response formats.
  • You can include image in JSON as a reference image; whether it takes effect depends on the actual image channel that is matched.
  • If n is omitted or explicitly set to 0, the unified layer falls back to 1.

Request Headers

Authorizationstring必填

Authentication header. Uses a Bearer token, e.g. Bearer YOUR_API_KEY.

Content-Typestring必填

Request content type, must be application/json.

Request Body

modelstring必填

Must be set to gpt-image-2.

promptstring

Generation prompt. For text-to-image semantics, this should be treated as required.

ninteger

Number of images to generate. If omitted or explicitly set to 0, the unified layer falls back to 1.

sizestring

Output size. The official gpt-image-2 accepts auto (default — the model picks a size from the prompt) and arbitrary WIDTHxHEIGHT custom sizes: both dimensions must be multiples of 16, aspect ratio between 1:3 and 3:1, longest edge up to 3840, and total pixels between 655360 and 8294400 (anything above 2560x1440 is experimental). Common base tiers are 1024x1024, 1536x1152, 1536x1024, 1024x1536, 1920x1080, 1080x1920.

imagestring | array<string> | object

Optional reference image input. Commonly written as a Base64 string or Base64 array, suitable for channels that require image style reference.

response_formatstring

Response format. Common values are url and b64_json.

qualitystring

Quality field. Official values are low, medium, high, auto (default auto). low suits fast drafts; high gives maximum fidelity at significantly higher token cost. Whether it actually takes effect depends on the final matched channel.

stylestring | object

Style field, passed through as-is to supported upstreams.

backgroundstring | object

Background control field, passed through as-is to supported upstreams. Note: the official gpt-image-2 only supports opaque and auto (default auto) — transparent is not supported (unlike gpt-image-1).

output_formatstring

Output image format. Official values are png (default), jpeg, webp.

output_compressioninteger

Output compression level, integer 0–100. Only applies when output_format is jpeg or webp.

moderationstring

Content moderation level. Official values are auto (default) and low (less restrictive filtering).

watermarkboolean

Explicit watermark switch. false and omission have different semantics.

Base Ratios and Size Tiers

PresetActual Target Size
1:11024x1024
4:31536x1152
3:21536x1024
2:31024x1536
16:91920x1080
9:161080x1920

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.

Request Examples

Response Examples

Response Fields

createdinteger

Generation timestamp.

dataarray<object>

Array of generation results.

urlstring

The image URL returned when response_format = url.

b64_jsonstring

The Base64 image data returned when response_format = b64_json.

revised_promptstring

Some upstreams rewrite the prompt and return it in this field.