OpenAI gpt-image-2. A single endpoint handles text-to-image and multi-image editing (up to 16 reference images, 30MB each); output composition is driven by aspect_ratio. Native 1K / 2K / 4K ($0.025 / $0.04 / $0.06). Async: POST creates the task, then poll with GET ?task_id= or supply a callback_url.
Authorization: Bearer YOUR_API_KEY| Model | model | Price | Notas |
|---|---|---|---|
| GPT Image 2 | gpt-image-2 | $0.025 / $0.04 / $0.06 | Async · 1K / 2K / 4K tiers |
/api/v1/images/generationscreate task/api/v1/images/generations?task_id=...poll status# ─── 1. Text-to-image ──────────────────────────────────────
# resolution: "1K" | "2K" | "4K" (optional, default 1K). aspect_ratio: 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16.
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",
"prompt": "A minimalist product shot of a white sneaker on a pastel gradient backdrop, soft studio lighting",
"aspect_ratio": "1:1",
"resolution": "2K"
}'
# Response:
# { "code": 200, "msg": "success", "data": { "taskId": "clxxx...", "state": "pending" } }
# ─── 2. Image editing with a reference URL ─────────────────
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",
"prompt": "Place this product on a marble kitchen counter with soft morning light",
"image_url": "https://example.com/product.jpg",
"aspect_ratio": "3:2"
}'
# ─── 3. Multi-image fusion (up to 10 reference images) ─────
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",
"prompt": "Use the model from image 1 wearing the outfit from image 2, studio lighting",
"image_urls": [
"https://example.com/model.jpg",
"https://example.com/outfit.jpg"
],
"aspect_ratio": "2:3"
}'
# ─── 4. Image editing via base64 ───────────────────────────
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",
"prompt": "Add a geometric fox logo in the center of the mug",
"image_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
"image_mime_type": "image/png",
"aspect_ratio": "1:1"
}'
# ─── 5. Poll task status ───────────────────────────────────
curl "https://apimodels.app/api/v1/images/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# Success response:
# {
# "code": 200,
# "msg": "success",
# "data": {
# "taskId": "clxxx...",
# "state": "completed",
# "resultUrls": ["https://r2.apimodels.app/images/xxx.png"],
# "costTime": 14320,
# "completeTime": 1705123465000
# }
# }
# ─── 6. Webhook callback (optional) ────────────────────────
# Add "callback_url" to the create request and your endpoint
# will receive a POST with the same payload when the task
# completes — useful for production to avoid 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",
"prompt": "Studio photo of a ceramic mug",
"aspect_ratio": "1:1",
"callback_url": "https://your-domain.com/webhook/image"
}'| Field | Required | Type | Description |
|---|---|---|---|
| model | Yes | string | Deve ser "gpt-image-2" |
| prompt | Yes | string | Prompt ou instruções de edição. Ao editar várias imagens, referencie-as como "image 1", "image 2". Comprimento de 1–20000 caracteres. |
| aspect_ratio | No | string | Output aspect ratio. Enum: 1:1 / 2:3 / 3:2 / 4:5 / 5:4 / 4:3 / 3:4 / 16:9 / 9:16 / 21:9. Omit or pass "auto" to let the model decide. Note: 5:4 and 4:5 are supported at 1K only — not at 2K/4K (use 1K, or switch to 3:4 / 4:3). |
| resolution | No | string | "1K" (default) / "2K" / "4K". Tiered pricing: 1K $0.025, 2K $0.04, 4K $0.06. |
| image_url | No | string | URL de uma única imagem de referência (acessível publicamente). Fornecê-la roteia para imagem para imagem. ≤ 10MB. |
| image_urls | No | string[] | Multiple reference image URLs (up to 16, ≤ 10MB each) for multi-image fusion. Beyond 16, only the first 16 are used. |
| image_base64 | No | string | Imagem de referência codificada em Base64 ou data-URI (para arquivos locais). Mutuamente exclusiva com image_url. |
| image_mime_type | No | string | Tipo MIME de image_base64. Valor padrão image/jpeg. Suporta image/png, image/jpeg, image/webp. |
| callback_url | No | string | URL do webhook chamada quando a tarefa é concluída. O servidor fará um POST para essa URL com o mesmo JSON da resposta de polling. |
| Field | Required | Type | Description |
|---|---|---|---|
| code | — | integer | 200 em caso de sucesso; caso contrário, consulte a tabela de códigos de erro. |
| msg | — | string | "success" ou uma mensagem de erro. |
| data.taskId | — | string | ID da tarefa usado para consultas de status. |
| data.state | — | string | pending / processing / completed / failed. |
| data.resultUrls | — | string[] | Presente apenas quando state=completed; URLs de imagens hospedadas no R2. Excluídas automaticamente após 7 dias — baixe ou re-hospede no seu próprio armazenamento o quanto antes. |
| data.failMsg | — | string | Presente apenas quando state=failed; motivo da falha do provedor upstream. |
| data.costTime | — | integer | Duração da tarefa em milissegundos. |
| data.completeTime | — | integer | Timestamp de conclusão em ms. |
Related: for the OpenAI-SDK-compatible sync channel see GPT Image 2 All; try it in the Playground
Tiered by resolution: 1K $0.025, 2K $0.04, 4K $0.06 per image — independent of aspect ratio or prompt length. Charged only on success.
POST /api/v1/images/generations with model gpt-image-2, a prompt, and image_url (single) or image_urls[] (up to 16). Poll GET ?task_id= until completed, or pass callback_url.
gpt-image-2 is the async task channel (1K/2K/4K tiers). gpt-image-2-all is the OpenAI-SDK-compatible sync channel with the full quality matrix and mask editing. gpt-image-2-lite is the cheapest channel: $0.008 per image, 1K only, sync.