GPT Image 2
GPT Image 2
GPT Image 2: qualidade fotorrealista, renderização precisa de texto e edição em nível de pixel
- Endpoint
- POST /api/v1/images/generate
- model
- gpt-image-2
- Output
- Image
- Credits
- from 3
Enviar uma tarefa
/api/v1/images/generateParâmetros
modelstringObrigatórioMust be "gpt-image-2"
typestringOpcionalPadrãotext-to-image"text-to-image" or "image-to-image" (default: text-to-image)
text-to-imageimage-to-imagepromptstringObrigatórioText description (3–20000 chars)
image_urlsstring[]OpcionalRequired for image-to-image. Up to 4 reference image URLs
input_imagestringOpcionalDeprecated. Alias for image_urls[0]
image_sizestringOpcionalOptional aspect ratio: "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5", "2:1", "1:2", "21:9", or "9:21". Required for 4k; auto/default is not allowed with 4k.
1:116:99:164:33:43:22:35:44:52:11:221:99:21resolutionstringOpcionalPadrão1kOptional output resolution: "1k", "2k", or "4k" (default: "1k")
1k2k4knum_imagesnumberOpcionalMust be 1 (gpt-image-2 always returns a single image)
Requisição
curl -X POST https://www.bananapro.site/api/v1/images/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"resolution": "2k",
"prompt": "A hand-drawn illustrated greeting card with the text \"Hello, world!\" in serif letters"
}'Resposta200
{
"success": true,
"data": {
"task_id": "task_gpt2_123",
"credits_used": 4,
"remaining_credits": 496,
"model": "gpt-image-2"
}
}Os valores de credits_used nestes exemplos são ilustrativos. O consumo real é calculado no envio e retornado pela API.
Consultar a tarefa
/api/v1/images/{task_id}status
pending- Accepted and waiting to start. Keep polling.
processing- Running. Keep polling.
completed- Finished. Read image_url; output holds the full result.
failed- Ended without a result. error_message says why and credits_refunded shows what was returned.
Poll every 5 to 10 seconds and stop at completed or failed, or register a webhook to be notified instead. Failed tasks are refunded automatically.
Requisição
curl https://www.bananapro.site/api/v1/images/task_abc123 \
-H "Authorization: Bearer sk-your-api-key"Resposta200
{
"success": true,
"data": {
"task_id": "task_abc123",
"model": "gpt-image-2",
"status": "completed",
"output": { "images": [{ "url": "https://..." }] },
"primary_url": "https://...",
"image_url": "https://...",
"error_message": null,
"credits_used": 4,
"credits_refunded": 0,
"created_at": "2026-10-04T10:00:00.000Z",
"updated_at": "2026-10-04T10:01:12.000Z",
"completed_at": "2026-10-04T10:01:12.000Z"
},
"request_id": "req_abc123"
}Aguardar o resultado
TASK_ID=task_abc123
while true; do
TASK=$(curl -s https://www.bananapro.site/api/v1/images/$TASK_ID \
-H "Authorization: Bearer sk-your-api-key")
STATUS=$(echo "$TASK" | jq -r '.data.status')
if [ "$STATUS" = "completed" ] || [ "$STATUS" = "failed" ]; then
echo "$TASK" | jq
break
fi
sleep 10
donePreços
| Resolution | Credits |
|---|---|
| 1k | 3 |
| 2k | 4 |
| 4k | 5 |
Funcionalidades
- Geração de texto para imagem
- Edição de imagem para imagem (até 4 imagens de referência)
- Qualidade fotorrealista e tipografia precisa
- Saída de imagem única (n=1)