Docs
All model guides
OpenAI · Image API

GPT Image 2

gpt-image-2

Production image generation with precise instructions, high-quality text, and 4K output.

POST/v1/images/generations
Output count1–1
Reference imagesUp to 16
Resolution tiers1K · 2K · 4K
Generation

Generate with GPT Image 2

Use ImgRouter's unified request contract and this model ID. The example uses recommended defaults from the route's current parameter guide.

cURL
curl https://api.imgrouter.com/v1/images/generations \
  -H "Authorization: Bearer $IMGROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: gpt-image-2-generate-001" \
  -d '{
  "model": "gpt-image-2",
  "prompt": "Editorial product photograph, precise materials, soft studio light",
  "size": "1:1",
  "resolution": "1K",
  "n": 1
}'

Request body

modelstring · requiredUse gpt-image-2.
promptstring · requiredGeneration or editing instruction between 1 and 5,000 characters.
sizestringSupported values: auto, 1:1, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 16:9, 9:16, 2:1, 1:2, 3:1, 1:3, 21:9, 9:21.
resolutionstringSupported values: 1K, 2K, 4K.
ninteger · 1–1Number of output images. Defaults to 1 and cannot exceed 1.
reference_imagesstring[] · max 16Public HTTPS source images. Send this field to the edit endpoint.
Controls

Supported options

Aspect ratio or size

auto1:13:22:34:33:45:44:516:99:162:11:23:11:321:99:21

Resolution

1K2K4K

Output format

url

Route notes

Supports generation and editing with up to sixteen reference images.

Only one output image is created per request.

Use an explicit ratio and resolution for predictable dimensions and pricing.

Reference workflow

Edit with reference images

Send public HTTPS source images with the same core controls. This route accepts up to 16 reference images.

POST/v1/images/edits
cURL
curl https://api.imgrouter.com/v1/images/edits \
  -H "Authorization: Bearer $IMGROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: gpt-image-2-edit-001" \
  -d '{
  "model": "gpt-image-2",
  "prompt": "Preserve the subject and composition. Change the scene to soft blue hour.",
  "size": "1:1",
  "resolution": "1K",
  "n": 1,
  "reference_images": [
    "https://example.com/reference.jpg"
  ]
}'

Describe both the intended change and the details that must remain consistent. Stable source URLs produce the most reliable edit requests.

Response

Read the completed output

Successful requests return completed image URLs and a request ID. Store the assets you need permanently; routed output URLs may expire.

200 · application/json
{
  "id": "req_01K4…",
  "object": "image.generation",
  "created": 1787424152,
  "data": [
    { "url": "https://static.imgrouter.com/images/req_01K4.webp" }
  ],
  "usage": { "images": 1 }
}

Use GET /v1/requests/{request_id} for reconciliation and GET /v1/balance for the authenticated key's current Credit position.