Documentation IndexFetch the complete documentation index at: /docs/llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Create, poll, list, and receive callbacks for EggAPI generation tasks
pending
processing
completed
failed
curl -X POST https://api.eggapi.ai/v1/generate \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "nanobanana", "prompt": "A dashboard hero image with glass UI panels", "aspect_ratio": "16:9", "num_outputs": 1 }'
{ "data": { "id": "gen_abc123def456", "status": "pending", "model": "nanobanana", "type": "image_generate", "cost": "$0.00", "created_at": "2026-05-08T10:30:00Z" }, "error": null }
curl https://api.eggapi.ai/v1/tasks/gen_abc123def456 \ -H "Authorization: Bearer YOUR_API_KEY"
{ "data": { "id": "gen_abc123def456", "status": "completed", "model": "nanobanana", "type": "image_generate", "output": { "url": "https://file.eggapi.ai/images/gen_abc123def456/0.png", "urls": ["https://file.eggapi.ai/images/gen_abc123def456/0.png"] }, "cost": "$0.0100", "created_at": "2026-05-08T10:30:00Z", "started_at": "2026-05-08T10:30:01Z", "completed_at": "2026-05-08T10:30:10Z" }, "error": null }
curl "https://api.eggapi.ai/v1/tasks?page=1&per_page=20" \ -H "Authorization: Bearer YOUR_API_KEY"
data.pagination
webhook_url
{ "model": "nanobanana", "prompt": "A studio portrait with soft lighting", "webhook_url": "https://example.com/eggapi/webhook" }
X-EggAPI-Timestamp
X-EggAPI-Signature
sha256=
{timestamp}.{raw_body}
{ "event": "task.completed", "task_id": "gen_abc123def456", "status": "completed", "model": "nanobanana", "output": { "urls": ["https://file.eggapi.ai/images/gen_abc123def456/0.png"] }, "cost": "0.010000", "timestamp": 1778217000 }
{ "event": "task.failed", "task_id": "gen_abc123def456", "status": "failed", "model": "nanobanana", "error": "generation failed: upstream provider unavailable", "cost": "0.000000", "timestamp": 1778217000 }
async function waitForTask(taskId, apiKey, timeoutMs = 300000) { const start = Date.now(); while (Date.now() - start < timeoutMs) { const response = await fetch(`https://api.eggapi.ai/v1/tasks/${taskId}`, { headers: { "Authorization": `Bearer ${apiKey}` } }); const { data, error } = await response.json(); if (error) throw new Error(error.message); if (data.status === "completed") return data; if (data.status === "failed") throw new Error(data.error || "Task failed"); await new Promise((resolve) => setTimeout(resolve, 3000)); } throw new Error("Task timed out"); }