> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eggapi.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Submit your first EggAPI generation task and read the result

This guide uses the production API base URL:

```text theme={null}
https://api.eggapi.ai
```

## 1. Get an API Key

Sign in at [eggapi.ai](https://eggapi.ai), open the dashboard, and create an API key. The public API only accepts API keys in the `Authorization` header:

```text theme={null}
Authorization: Bearer YOUR_API_KEY
```

## 2. Submit a Task

All currently documented public generation models are asynchronous. `POST /v1/generate` returns `202 Accepted` and a task object.

<CodeGroup>
  ```bash cURL theme={null}
  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 cinematic product photo of a matte green travel mug",
      "aspect_ratio": "16:9",
      "num_outputs": 1,
      "webhook_url": "https://webhook.site/your-webhook-id"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.eggapi.ai/v1/generate",
      headers={"Authorization": "Bearer YOUR_API_KEY"},
      json={
          "model": "nanobanana",
          "prompt": "A cinematic product photo of a matte green travel mug",
          "aspect_ratio": "16:9",
          "num_outputs": 1,
          "webhook_url": "https://webhook.site/your-webhook-id",
      },
  )

  response.raise_for_status()
  task = response.json()["data"]
  print(task["id"])
  ```

  ```javascript JavaScript theme={null}
  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: "nanobanana",
      prompt: "A cinematic product photo of a matte green travel mug",
      aspect_ratio: "16:9",
      num_outputs: 1,
      webhook_url: "https://webhook.site/your-webhook-id"
    })
  });

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

Example response:

```json theme={null}
{
  "data": {
    "id": "gen_abc123def456",
    "status": "pending",
    "model": "nanobanana",
    "type": "image_generate",
    "cost": "$0.00",
    "created_at": "2026-05-08T10:30:00Z"
  },
  "error": null
}
```

## 3. Poll the Task

Use the task ID from the response:

```bash theme={null}
curl https://api.eggapi.ai/v1/tasks/gen_abc123def456 \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Completed task response:

```json theme={null}
{
  "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:12Z"
  },
  "error": null
}
```

## 4. Check Usage

Usage endpoints require an API key:

```bash theme={null}
curl https://api.eggapi.ai/v1/usage/summary \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Example response:

```json theme={null}
{
  "data": [
    {
      "model": "nanobanana",
      "total_units": 1,
      "total_cost": "$0.0100",
      "request_count": 1
    }
  ],
  "error": null
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Models" icon="cube" href="/docs/en/guides/models">
    Choose the right model ID and parameters.
  </Card>

  <Card title="Async Tasks" icon="clock" href="/docs/en/guides/async-tasks">
    Poll tasks, consume webhooks, and handle retries.
  </Card>
</CardGroup>
