OpenAI-compatible sync image API for GPT Image 2 — point the OpenAI SDK, Codex, or Cursor at our base_url and it works as-is. Full resolution × quality matrix (1K/2K/4K × low/medium/high/auto), text-to-image plus multi-image editing (up to 16 reference images + mask), synchronous responses with no polling.
All requests carry the API key in the header:
Authorization: Bearer YOUR_API_KEY| Field | Required | Type | Description |
|---|---|---|---|
| Tier | low | medium / auto | high |
| 1K | $0.005 | $0.025 | $0.07 |
| 2K | $0.01 | $0.04 | $0.10 |
| 4K | $0.015 | $0.06 | $0.23 |
Billed per image; quality=auto is charged at the medium tier; failed requests are not charged. Speed scales with quality: low ~40s, medium ~60-90s, high ~2 minutes.
| Field | Required | Type | Description |
|---|---|---|---|
| Tier | Typical sizes | Tier rule | |
| 1K | 1024x1024 / 1536x1024 / 1024x1536 | long edge ≤ 1536 | |
| 2K | 2048x2048 / 2048x1152 / 1152x2048 | long edge 1537-2048 | |
| 4K | 3840x2160 / 2160x3840 | long edge > 2048 |
Arbitrary WxH is also supported: both sides multiples of 16, long edge ≤ 3840, aspect ratio ≤ 3:1, total pixels 655K-8.29M. Alternatively omit size and pass aspect_ratio + resolution (1K/2K/4K) and the server derives the best size.
/api/v1/images/generations·POST/api/v1/images/editsPassing an OpenAI-style WxH size triggers sync mode: the response carries the image inline (b64_json + url), matching the official images.generate() / images.edit() contract.
# Text-to-image — OpenAI Images API shape, SYNC response (no task polling)
curl -X POST https://apimodels.app/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-all",
"prompt": "a white sneaker product shot on beige background, studio light",
"size": "2048x2048",
"quality": "medium",
"n": 1
}'
# → { "created": ..., "data": [{ "b64_json": "...", "url": "https://r2.apimodels.app/..." }] }
# Image edit / multi-image fusion — multipart, OpenAI images.edit() shape
curl -X POST https://apimodels.app/api/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2-all" \
-F "image=@product.png" \
-F "prompt=put this sneaker on a model, e-commerce close-up" \
-F "size=2048x2048" \
-F "quality=medium"Without a WxH size (or when you need callback_url) the request follows the platform async contract: create returns a taskId; poll until completed, or receive a webhook callback.
# Native async contract — pass aspect_ratio + resolution tier instead of size.
curl -X POST https://apimodels.app/api/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-all",
"prompt": "a lighthouse on a cliff at dusk",
"aspect_ratio": "9:16",
"resolution": "2K",
"quality": "medium",
"callback_url": "https://your-domain.com/webhook"
}'
# → { "code": 200, "data": { "taskId": "..." } }
curl "https://apimodels.app/api/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"| Field | Required | Type | Description |
|---|---|---|---|
| Field | Type | Description | |
| model | string | gpt-image-2-all | |
| prompt | string | Prompt (required) | |
| size | string | WxH — triggers sync mode; see the size table | |
| quality | string | low / medium / high / auto (default medium; auto billed as medium) | |
| aspect_ratio + resolution | string | Async alternative to size: ratio + 1K/2K/4K tier | |
| image / image_base64 / image_url | string | Reference image → auto-routes to the edit endpoint | |
| image_urls / images | string[] | Multi-image fusion, up to 16 | |
| mask_url / mask_base64 | string | Mask inpainting (transparent = repaint) | |
| background | string | transparent / opaque / auto | |
| response_format | string | b64_json (default) or url (edits endpoint) | |
| n | number | Number of images (billed × n) |
Try it in the Playground