Get API Key Get API
Docs

GPT-Image-2 Official Channel Image Generation

- OpenAI official `gpt-image-2` model, based on `/v1/images/generations` compatible protocol

  • Asynchronous processing, returns task_id for subsequent queries
  • Text-to-image / image-to-image / inpainting (mask) — all-in-one
  • Supports PNG / WebP transparent backgrounds (Alpha channel)
  • New resolution tier field — 1K / 2K / 4K selection
  • 15 aspect ratios supported across the 1K / 2K / 4K tiers
  • Up to 4 images per request, up to 16 reference images
  • 95% parameter alignment with gpt-image-1.5-official — migration only requires changing the model name

Request example

curl --request POST \
  --url https://api.openveer.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-2-official",
    "prompt": "An ancient castle beneath a starry sky",
    "size": "16:9",
    "resolution": "2k",
    "quality": "high",
    "n": 1
  }'

Response example

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

Authorizations

Authorization string

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:

Authorization: Bearer YOUR_API_KEY

Body

model string

Image generation model name

Fixed to gpt-image-2-official (OpenAI official gpt-image-2 model)

nsfw_check boolean

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)
prompt string

Text description for image generation

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

Image aspect ratio

Externally uses ratio values; internally mapped to actual pixels according to resolution.

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

  • auto - Automatic (server picks a ratio based on prompt / reference images)
  • 1:1 - Square (default, social avatars / logos)
  • 3:2 - Landscape (common DSLR ratio)
  • 2:3 - Portrait (vertical posters)
  • 4:3 - Landscape (classic monitor / slideshow)
  • 3:4 - Portrait
  • 5:4 - Landscape
  • 4:5 - Portrait (Instagram vertical post)
  • 16:9 - Landscape (widescreen video thumbnail)
  • 9:16 - Portrait (phone full-screen / short video cover)
  • 2:1 - Landscape (web banner)
  • 1:2 - Portrait
  • 3:1 - Landscape (ultra-wide banner)
  • 1:3 - Portrait (extra-tall poster)
  • 21:9 - Landscape (cinematic ultra-wide)
  • 9:21 - Portrait

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

Warning



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

resolution string

Resolution tier (new field)

Controls the actual output clarity.

  • 1k - 1024 baseline, cost-efficient for daily use (default)
  • 2k - 2048 baseline, suitable for posters / high-definition needs
  • 4k - 3840 baseline, supports the 15 ratios in the mapping table below

Warning



4K supports the 15 ratios in the mapping table below; you can also pass the pixel dimensions from the table directly via size.

quality string

Image quality

  • auto - Automatic (default, typically equivalent to low)
  • low - Fast and economical, sufficient for rough outlines
  • medium - Balanced
  • high - Maximum precision (4K + high can take >120s)
moderation string

Moderation strength

  • auto - Default moderation strength
  • low - More lenient moderation
output_format string

Output format

  • png - Default format; supports transparent backgrounds
  • jpeg - Smaller files; does not support an Alpha channel
  • webp - Supports transparent backgrounds; suitable for modern browsers
output_compression integer

Output compression level, range 0-100

  • Only effective for jpeg / webp
n integer

Number of images to generate

Range: 1 ~ 4

Warning



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

image_urls array

Reference image URL array

* Up to 20 MB per image, 256 MB total cap
* Up to **16** reference images; more will be rejected
* Must be publicly accessible, stable image URLs
mask_url string

Mask image URL, used for inpainting

  • Must be used together with image_urls

Warning



1. Ensure the mask image has an Alpha channel before uploading.

2. The mask image dimensions must **match the first reference image**.

Size × Resolution Mapping

size × resolution → OpenAI actual pixels (15 ratios × 3 tiers):

size 1k 2k 4k
1:1 1024×1024 2048×2048 2880×2880
3:2 1536×1024 2048×1360 3520×2336
2:3 1024×1536 1360×2048 2336×3520
4:3 1024×768 2048×1536 3312×2480
3:4 768×1024 1536×2048 2480×3312
5:4 1280×1024 2560×2048 3216×2576
4:5 1024×1280 2048×2560 2576×3216
16:9 1536×864 2048×1152 3840×2160
9:16 864×1536 1152×2048 2160×3840
2:1 2048×1024 2688×1344 3840×1920
1:2 1024×2048 1344×2688 1920×3840
3:1 1881×836 / 1536×512 3072×1024 3840×1280
1:3 887×1774 / 512×1536 1024×3072 1280×3840
21:9 2016×864 2688×1152 3840×1648
9:21 864×2016 1152×2688 1648×3840

Note: Some dimensions are approximated based on multiples of 16 and pixel limits, such as 3:2 / 2:3 @ 2K being 2048×1360 and 21:9 @ 4K being 3840×1648. Use the actual pixels in the table as the source of truth.

Usage Examples

Text-to-image (minimal request)

{
  "model": "gpt-image-2-official",
  "prompt": "An ancient castle beneath a starry sky"
}

Text-to-image (transparent sticker)

{
  "model": "gpt-image-2-official",
  "prompt": "A cute cartoon orange cat sticker, full body, thick white outline, flat vector style, isolated on a fully transparent background",
  "size": "1:1",
  "resolution": "1k",
  "quality": "medium",
  "output_format": "png",
  "n": 1
}

Image-to-image (remove background)

{
  "model": "gpt-image-2-official",
  "prompt": "Remove the background, keep only the product, isolated on a fully transparent background",
  "image_urls": ["https://your-cdn.com/product.jpg"],
  "size": "1:1",
  "resolution": "1k",
  "output_format": "png"
}

2K high-definition poster

{
  "model": "gpt-image-2-official",
  "prompt": "Cyberpunk night scene",
  "size": "16:9",
  "resolution": "2k",
  "quality": "high",
  "output_format": "jpeg",
  "output_compression": 90
}

4K wallpaper

{
  "model": "gpt-image-2-official",
  "prompt": "Snow mountain sunrise panorama",
  "size": "16:9",
  "resolution": "4k",
  "quality": "high",
  "n": 1
}

Image-to-image (multi-reference fusion)

{
  "model": "gpt-image-2-official",
  "prompt": "Fuse the two reference images into a single illustration poster, preserving the main silhouettes",
  "size": "1:1",
  "quality": "high",
  "image_urls": [
    "https://your-cdn.com/input-a.png",
    "https://your-cdn.com/input-b.png"
  ]
}

Inpainting (mask)

{
  "model": "gpt-image-2-official",
  "prompt": "Replace the background with a desert sunset",
  "size": "1:1",
  "quality": "medium",
  "image_urls": ["https://your-cdn.com/photo.png"],
  "mask_url": "https://your-cdn.com/mask.png"
}

Multiple images (n > 1)

{
  "model": "gpt-image-2-official",
  "prompt": "Four minimalist poster variations of a red fox",
  "size": "1:1",
  "quality": "low",
  "n": 4
}

Direct pixel string (advanced)

{
  "model": "gpt-image-2-official",
  "prompt": "wide cinematic shot",
  "size": "3840x2160",
  "quality": "high"
}

Response

code integer

Response status code

data array
Response data array
status string

Task status

  * submitted - Submitted
task_id string

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

{
  "code": 200,
  "data": {
    "actual_time": 14,
    "completed": 1784607890,
    "cost": 0.004792,
    "created": 1784607876,
    "credits_cost": 0.047920000000000004,
    "estimated_time": 60,
    "id": "task_01KPTXXXXXXXXXXXXXXX",
    "progress": 100,
    "result": {
      "images": [
        {
          "expires_at": 1784694290,
          "url": [
            "https://upload.openveer.com/f/image/xxxxxxxx-gpt_image_2_official_task_xxx_0.png"
          ]
        }
      ]
    },
    "status": "completed",
    "usage": {
      "input_tokens": 22,
      "input_tokens_details": {
        "cached_tokens": 0,
        "image_tokens": 0,
        "text_tokens": 22
      },
      "output_tokens": 196,
      "output_tokens_details": {
        "image_tokens": 196,
        "text_tokens": 0
      },
      "total_tokens": 218
    }
  }
}

The usage field reports the billable token usage for this request:

Field Description
input_tokens Total input tokens consumed
input_tokens_details.cached_tokens Input tokens served from cache
input_tokens_details.image_tokens Tokens used by input images
input_tokens_details.text_tokens Tokens used by input text (prompt)
output_tokens Total output tokens consumed
output_tokens_details.image_tokens Tokens used by the generated image
output_tokens_details.text_tokens Tokens used by output text
total_tokens Total tokens, equal to input_tokens + output_tokens

For image generation the output is mostly image tokens, so output_tokens_details.image_tokens usually equals output_tokens. In the example above, total_tokens = 22 + 196 = 218.

Task status flow: submitted → in_progress → completed / failed.

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

This documentation is built and hosted on Mintlify, a developer documentation platform.