Skip to content
Diese Seite ist noch nicht in Ihrer Sprache verfügbar und wird deshalb auf Englisch angezeigt.

GPT-Image-2 Image Generation

Asynchronous processing mode, returns task ID for subsequent queries

Gesamte Dokumentation
POST/v1/images/generations
  • OpenAI Images compatible protocol, supports text-to-image / image-to-image

  • 15 image aspect ratios supported via the size field

  • Output pixel tier controlled via resolution (1k / 2k / 4k)

  • Up to 15 reference images, URL and base64 can be mixed

  • Billed by resolution tier (1K / 2K / 4K)

Note

Model name compatibility note: This endpoint also accepts the alias gpt-image-2-ext, which is equivalent to gpt-image-2. The two are interchangeable and produce identical results.

Anfragebeispiele

# model can be "gpt-image-2", or the compatible alias "gpt-image-2-ext"
curl --request POST \
  --url https://api.apisea.ai/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2",
    "prompt": "A ginger cat sitting on a windowsill watching the sunset, watercolor style",
    "n": 1,
    "size": "16:9",
    "resolution": "2k"
  }'

Authorizations

Authorizationstringrequired

All endpoints require Bearer Token authentication

Get your API Key:

Visit the API Key management page to get your API Key

Include it in the request header:

text
Authorization: Bearer YOUR_API_KEY

Body

modelstringrequireddefault: gpt-image-2

Image generation model name

Fixed to gpt-image-2 (compatible alias gpt-image-2-ext)

Note

For backward compatibility, the alias gpt-image-2-ext (for gpt-image-2) remains usable.

nsfw_checkbooleandefault: false

Whether to run content moderation before submitting the image task.

  • true: use omni-moderation-latest to review prompts and input images
  • false or omitted: do not send a moderation request, adding no moderation cost or latency (default)
promptstringrequired

Text description for image generation

  • Supports English and Chinese, detailed descriptions recommended
  • Pre-submission content moderation / safety review — violations are rejected immediately
nintegerdefault: 1

Number of images to generate

Value: 1

Warning

Must be a pure number (e.g., 1), do not wrap in quotes

sizestringdefault: 1:1

Image aspect ratio

Supported ratios, plus auto to let the server pick a suitable ratio automatically:

sizeType
autoAutomatic
1:1Square
3:2Landscape
2:3Portrait
4:3Landscape
3:4Portrait
5:4Landscape
4:5Portrait
16:9Landscape
9:16Portrait
2:1Landscape
1:2Portrait
3:1Landscape
1:3Portrait
21:9Landscape
9:21Portrait

Pixel dimensions can also be passed directly, such as 1881x836 / 887x1774.

Warning

When size is set to auto, the default ratio is 1:1.

resolutionstringdefault: 1k

Output resolution tier

Options: 1k / 2k / 4k

size × resolution → actual pixel mapping:

size1k2k4k
1:11024×1024 / 1254×12542048×20482880×2880
3:21536×10242048×13603520×2336
2:31024×15361360×20482336×3520
4:31024×7682048×15363312×2480
3:4768×10241536×20482480×3312
5:41280×1024 / 1448×10862560×20483216×2576
4:51024×1280 / 1122×14022048×25602576×3216
16:91536×864 / 1672×9412048×11523840×2160
9:16864×1536 / 941×16721152×20482160×3840
2:12048×1024 / 1774×8872688×13443840×1920
1:21024×2048 / 887×17741344×26881920×3840
3:11881×836 / 1536×5123072×10243840×1280
1:3887×1774 / 512×15361024×30721280×3840
21:92016×864 / 1915×8212688×11523840×1648
9:21864×2016 / 821×19151152×26881648×3840

Warning

4K supports the 15 ratios listed above; you can also pass the pixel dimensions from the table directly via size.

image_urlsarray

Reference image array (OpenAI standard field). Switches to image-to-image mode when provided.

Details

  • Up to 15 reference images, exceeding returns image_urls exceeds max 15
  • Max 20 MB per image, 256 MB in total
  • Supports image URL (public stable link)
  • Supports base64 data URI (e.g. data:image/png;base64,...)
  • URL and base64 can be mixed in the same array, handled by the server
  • Without size, output resolution = input image resolution; with size, output is forced to the specified ratio

Note

Other OpenAI standard fields (response_format, style) are not supported and will be ignored. Task results only return url — please download and convert to base64 yourself if needed.

official_fallbackbooleandefault: false

Whether to fall back to the official channel

  • false: Do not use (default)
  • true: Use the official channel

Usage Examples

Text-to-image (minimal request)

json
{
  "model": "gpt-image-2",
  "prompt": "A ginger cat sitting on a windowsill watching the sunset, watercolor style"
}

Text-to-image (with ratio + 2K)

json
{
  "model": "gpt-image-2",
  "prompt": "a corgi astronaut on the moon, cinematic, 8k",
  "size": "16:9",
  "resolution": "2k"
}

Text-to-image (4K output)

json
{
  "model": "gpt-image-2",
  "prompt": "An ancient castle under a starry sky",
  "size": "16:9",
  "resolution": "4k"
}

Text-to-image (multiple images)

json
{
  "model": "gpt-image-2",
  "prompt": "An ancient castle under a starry sky",
  "size": "16:9",
  "resolution": "4k",
  "n": 2
}

Image-to-image (reference = URL)

json
{
  "model": "gpt-image-2",
  "prompt": "Turn this photo into a watercolor painting",
  "image_urls": [
    "https://example.com/photo.jpg"
  ]
}

Image-to-image (reference = base64)

json
{
  "model": "gpt-image-2",
  "prompt": "Turn this photo into a watercolor painting",
  "image_urls": [
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  ]
}

Image-to-image (multi-reference fusion, URL + base64 mixed)

json
{
  "model": "gpt-image-2",
  "prompt": "Fuse these two photos into a single poster",
  "size": "4:3",
  "resolution": "2k",
  "image_urls": [
    "https://example.com/photo-a.jpg",
    "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  ]
}

Response

codeinteger

Response status code

dataarray

Response data array

Properties

statusstring

Task status

  • submitted - Submitted
task_idstring

Unique task identifier, used for subsequent result queries

Querying Task Results

After successful submission, a task_id is returned. Poll the task status via GET /v1/tasks/{task_id}, see Task Query API for details.

Success Response Example

json
{
  "code": 200,
  "data": {
    "id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
    "status": "completed",
    "progress": 100,
    "created": 1776748674,
    "completed": 1776748726,
    "actual_time": 52,
    "cost": 0.05279,
    "credits_cost": 0.5279,
    "estimated_time": 100,
    "result": {
      "images": [
        {
          "url": [
            "https://cdn.example.com/f/image/xxxxxxxx-gpt_image_2_task_xxx_0.png"
          ],
          "expires_at": 1776835126
        }
      ]
    }
  }
}

Image access: data.result.images[0].url[0]

Task Status

StatusMeaning
submittedSubmitted
processingBeing processed upstream
completedSuccess, result.images available
failedFailed, check error.message

Antworten

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA"
    }
  ]
}

Einen Fehler in dieser Dokumentation gefunden? Schreiben Sie an support@apisea.ai.