> ## 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.

# nanobanana

> 公开 nano-banana 图片生成和图片编辑 API

`nanobanana` 是公开 nano-banana 目录模型对应的 API model ID。它通过同一个 `POST /v1/generate` 端点支持异步图片生成和图片编辑。

| 字段 | 值 |
| - | - |
| 前台公开名称 | `nano-banana` |
| API model ID | `nanobanana` |
| 处理方式 | 异步任务 |
| 生成任务类型 | `image_generate` |
| 编辑任务类型 | `image_edit` |
| 基础单价 | 每张输出图 `$0.0100` |

## 生成图片

<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 clean editorial photo of a lemon tart on a steel table",
      "aspect_ratio": "16:9",
      "num_outputs": 1
    }'
  ```

  ```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 clean editorial photo of a lemon tart on a steel table",
          "aspect_ratio": "16:9",
          "num_outputs": 1,
      },
  )

  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 clean editorial photo of a lemon tart on a steel table",
      aspect_ratio: "16:9",
      num_outputs: 1
    })
  });

  const { data: task } = await response.json();
  console.log(task.id);
  ```
</CodeGroup>

响应：

```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
}
```

继续使用 `GET /v1/tasks/{id}` 轮询最终输出。

## 编辑图片

传入 `image_urls` 会切换到图片编辑模式：

```bash 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": "Replace the background with a quiet marble kitchen",
    "image_urls": ["https://example.com/input.png"]
  }'
```

响应：

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

## 完成后的输出

```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:10Z"
  },
  "error": null
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.