Skip to content
RU

GPT Image 2

GPT Image 2 (openai/gpt-image-2) is OpenAI’s image generation model. It works with two endpoints: POST /v1/images/generations for text-to-image and POST /v1/images/edits for working from a reference image. The model is paid — generations are charged from your balance.

Field Description
model openai/gpt-image-2 (or the short gpt-image-2)
prompt What to draw, required ; up to 32,000 characters
n How many images, 1 to 4; each one is billed separately
aspect_ratio 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9; defaults to 1:1
resolution 1k, 2k or 4k; defaults to 1k
size Explicit WxH from the model’s fixed table
quality The model has no such knob: passing the parameter returns 400

GPT Image 2 sizes are not computed from the aspect ratio — they come from a table fixed per “resolution + aspect” pair. Common combinations:

Aspect 1k 2k 4k
1:1 1024x1024 2048x2048 2880x2880
16:9 1792x1024 2048x1152 3840x2160
9:16 1024x1792 1152x2048 2160x3840
4:3 1024x1024 2048x1536 3328x2496
21:9 1792x1024 2880x1232 4480x1920

Note the 1k column: several different aspects yield the same WxH. For this model it is safer to pass aspect_ratio + resolution and treat size as compatibility — on a collision, the reverse WxH → aspect mapping picks the first matching option.

import base64
img = client.images.generate(
model="openai/gpt-image-2",
prompt="Isometric illustration of a book cafe, warm palette, fine detail",
extra_body={"aspect_ratio": "16:9", "resolution": "2k"},
)
with open("cafe.png", "wb") as f:
f.write(base64.b64decode(img.data[0].b64_json))
{
"model": "openai/gpt-image-2",
"prompt": "Podcast cover about space: minimalism, deep blue, stardust",
"size": "2880x1232"
}

The model accepts reference images (references: true), so /v1/images/edits is available:

curl https://api.mixen.ai/v1/images/edits \
-H "Authorization: Bearer $MIXEN_API_KEY" \
-F model=openai/gpt-image-2 \
-F image=@cat.png \
-F prompt="Dress the cat as an astronaut, keep the background"

The answer always carries b64_json. Both endpoints answer synchronously — set your HTTP client timeout to at least 120 seconds.

4.0108 ₽ ($0.045) per image — the flat catalog price. Current values — catalog.

  • Twenty-three fixed sizes across three resolutions — from 1024x1024 up to 3840x2160 and 4480x1920.
  • Ten frame formats, including the panoramic 21:9 for banners and covers.
  • Editing from a reference via /v1/images/edits — the same key and syntax as generation.
  • At 1k different aspects produce the same WxH — pass aspect_ratio + resolution, not size.
  • No quality knob; a size outside the model’s table returns 400.
  • Balance only — the model is not part of the free quota.

All models — in the catalog. The general image workflow — images guide.