GPT-Image-2
Standard gpt-image-2 text-to-image and image-to-image via async tasks.
GPT-Image-2 image generation
- Model:
gpt-image-2 - Endpoint:
POST https://apimaster.ai/v1/images/generations - Mode: Async — returns
task_id, then poll the task - Features: Text-to-image; image-to-image with up to 16 reference images (URL + base64 mix)
Auth
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Body parameters
| Field | Type | Required | Notes |
|---|---|---|---|
model |
string | yes | gpt-image-2 |
prompt |
string | yes | Scene description; safety moderation applies |
n |
integer | no | 1 only (numeric, no quotes) |
size |
string | no | Aspect ratio, default 1:1 |
resolution |
string | no | 1k / 2k / 4k, default 1k |
image_urls |
array | no | Reference images → image-to-image |
official_fallback |
boolean | no | Official channel fallback, default false |
size 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, or pixel strings like 3840x2160.
resolution (sample pixels)
| size | 1k | 2k | 4k |
|---|---|---|---|
1:1 |
1024×1024 | 2048×2048 | 2880×2880 |
16:9 |
1536×864 | 2048×1152 | 3840×2160 |
All 15 ratios support 4K.
image_urls
- Max 16 images
- Public URLs and base64 data URIs can be mixed
- Omit
sizeto follow input resolution; setsizeto force output aspect ratio
Examples
Minimal text-to-image
{
"model": "gpt-image-2",
"prompt": "An orange cat on a windowsill at sunset, watercolor"
}
16:9 @ 2K
curl -s "https://apimaster.ai/v1/images/generations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "a corgi astronaut on the moon, cinematic",
"size": "16:9",
"resolution": "2k"
}'
Submit response
{
"code": 200,
"data": [{ "status": "submitted", "task_id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA" }]
}
| HTTP | Meaning |
|---|---|
| 400 | Invalid parameters |
| 401 | Bad API key |
| 402 | Insufficient balance |
| 429 | Rate limited |
Poll task result
curl -s "https://apimaster.ai/v1/tasks/TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
Image URL: data.result.images[0].url[0]
| status | Meaning |
|---|---|
submitted |
Queued |
processing |
Running |
completed |
Ready |
failed |
See error |
Poll after 10–20s, every 3–5s. Batch: POST https://apimaster.ai/v1/tasks/batch with {"task_ids":[...]}.
Notes
- Async only — no synchronous image URL in the create response.
- Prefer
sizefor aspect ratio; avoid repeating ratio inprompt. - Billing by resolution tier; see console for your account.
Compare with official channel.