EggAPI/docs / quickstart
sign in

Quickstart

Submit your first EggAPI image or video task and read the result

This guide uses the production API base URL:

text
https://api.eggapi.ai

1. Get an API Key

Sign in at eggapi.ai, open the dashboard, top up your balance, and create an API key. Send the key in the Authorization header of every request:

text
Authorization: Bearer YOUR_API_KEY

2. Submit a Task

Every generation model is asynchronous. POST /v1/generate returns 202 Accepted and a task object; the output arrives later.

bash
curl -X POST https://api.eggapi.ai/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/nano-banana-2/text-to-image",
    "prompt": "A cinematic product photo of a matte green travel mug",
    "aspect_ratio": "16:9",
    "resolution": "1k",
    "num_outputs": 1
  }'
python
import requests

response = requests.post(
    "https://api.eggapi.ai/v1/generate",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "google/nano-banana-2/text-to-image",
        "prompt": "A cinematic product photo of a matte green travel mug",
        "aspect_ratio": "16:9",
        "resolution": "1k",
        "num_outputs": 1,
    },
)

response.raise_for_status()
task = response.json()["data"]
print(task["id"])
javascript
const response = await fetch("https://api.eggapi.ai/v1/generate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "google/nano-banana-2/text-to-image",
    prompt: "A cinematic product photo of a matte green travel mug",
    aspect_ratio: "16:9",
    resolution: "1k",
    num_outputs: 1
  })
});

if (!response.ok) throw new Error(await response.text());
const { data: task } = await response.json();
console.log(task.id);

Example response:

json
{
  "data": {
    "id": "gen_3f2a9c1d-7b4",
    "status": "pending",
    "model": "google/nano-banana-2/text-to-image",
    "type": "image_generate",
    "cost": "$0.00",
    "created_at": "2026-10-26T10:30:00Z"
  },
  "error": null
}

3. Poll the Task

Use the task ID from the response:

bash
curl https://api.eggapi.ai/v1/tasks/gen_3f2a9c1d-7b4 \
  -H "Authorization: Bearer YOUR_API_KEY"

Completed task response:

json
{
  "data": {
    "id": "gen_3f2a9c1d-7b4",
    "status": "completed",
    "model": "google/nano-banana-2/text-to-image",
    "type": "image_generate",
    "output": {
      "url": "https://file.eggapi.ai/images/gen_3f2a9c1d-7b4/0.png",
      "urls": ["https://file.eggapi.ai/images/gen_3f2a9c1d-7b4/0.png"]
    },
    "cost": "$0.0135",
    "created_at": "2026-10-26T10:30:00Z",
    "started_at": "2026-10-26T10:30:01Z",
    "completed_at": "2026-10-26T10:30:12Z"
  },
  "error": null
}

Images usually finish in seconds; videos usually take one to three minutes. Instead of polling you can pass webhook_url when you create the task. See Async Tasks.

4. Generate a Video

Video models need a duration in seconds, because video is billed per second:

bash
curl -X POST https://api.eggapi.ai/v1/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedance-2.5/text-to-video",
    "prompt": "A black egg cracking open under soft studio light, slow push-in",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }'

To animate your own image, upload it with POST /v1/uploads and pass the returned URL in image_urls to an image-to-video model. See Video Models.

5. Check Usage

Usage endpoints require an API key:

bash
curl https://api.eggapi.ai/v1/usage/summary \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response:

json
{
  "data": [
    {
      "model": "google/nano-banana-2/text-to-image",
      "total_units": 1,
      "total_cost": "$0.0135",
      "request_count": 1
    }
  ],
  "error": null
}

Next Steps

  • Models: Pick a model ID and see the parameters it accepts.
  • Async Tasks: Poll tasks, consume webhooks, and handle failures.
  • Uploads: Host input images, videos, and audio for editing and video models.
  • MCP: Connect Claude Code, Codex, or Cursor to EggAPI.
connected
mcp https://api.eggapi.ai/mcp
models ...
Claude Code · Codex · MCP
█