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

# Image introduction

# Gemini 图像生成（Nano Banana）

使用 Google 的 **Nano Banana** 模型创建和编辑高质量图像。支持文生图和图像编辑，提供多种宽高比，分辨率最高达 4K。

## 支持的模型

| 模型                 | 说明                               | 最大分辨率 |
| ------------------ | -------------------------------- | ----- |
| `nano-banana-fast` | 快速生成（默认）—— 质量与速度平衡               | 1K    |
| `nano-banana-pro`  | 专业级质量 —— 支持最高 4K                 | 4K    |
| `nano-banana-2`    | 最新模型 —— 支持扩展宽高比（1:4、4:1、1:8、8:1） | 4K    |

## 功能特性

<CardGroup cols={2}>
  <Card title="文生图" icon="wand-magic-sparkles">
    通过 `action: "generate"` 从文本提示词生成图像
  </Card>

  <Card title="图像编辑" icon="pen">
    通过 `action: "edit"` 和参考图 URL 编辑已有图像
  </Card>

  <Card title="灵活的宽高比" icon="expand">
    21:9、16:9、9:16、4:3、3:2、5:4、1:1 等 —— nano-banana-2 额外支持 1:8 / 8:1
  </Card>

  <Card title="高分辨率" icon="image">
    Pro 和 2 模型支持 1K / 2K / 4K 输出
  </Card>
</CardGroup>

## 使用流程

<Steps>
  <Step title="创建图像任务">
    调用 `POST /gemini/image/generate`，传入提示词、模型和宽高比，返回 `taskId`。
  </Step>

  <Step title="轮询任务结果">
    使用 `GET /gemini/task/result?taskId=xxx` 轮询直到 status 为 `completed`，结果包含生成的图像。
  </Step>
</Steps>

## 快速示例

<CodeGroup>
  ```bash 生成图像 theme={null}
  curl -X POST "https://api.mountsea.ai/gemini/image/generate" \
    -H "Authorization: Bearer your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "A futuristic city skyline at night, neon lights reflecting on wet streets",
      "action": "generate",
      "model": "nano-banana-pro",
      "aspect_ratio": "16:9",
      "resolution": "2K"
    }'
  ```

  ```bash 编辑图像 theme={null}
  curl -X POST "https://api.mountsea.ai/gemini/image/generate" \
    -H "Authorization: Bearer your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Add snow to the scene",
      "action": "edit",
      "model": "nano-banana-fast",
      "image_urls": ["https://example.com/source.jpg"],
      "aspect_ratio": "1:1"
    }'
  ```

  ```bash 轮询任务状态 theme={null}
  curl -X GET "https://api.mountsea.ai/gemini/task/result?taskId=your-task-id" \
    -H "Authorization: Bearer your-api-key"
  ```
</CodeGroup>

## 宽高比

| 宽高比                                        | 标准模型 | 仅 nano-banana-2 |
| ------------------------------------------ | ---- | --------------- |
| 1:1、4:3、3:2、5:4、3:4、4:5、16:9、9:16、21:9、2:3 | ✅    | ✅               |
| 1:4、4:1、1:8、8:1                            | ❌    | ✅               |

## 分辨率选项

* **`nano-banana-fast`** —— 固定 1K
* **`nano-banana-pro`** —— `1K` / `2K` / `4K`
* **`nano-banana-2`** —— `1K` / `2K` / `4K`

<Tip>
  如需特殊宽高比（如 1:8 垂直条幅或 8:1 水平条幅），使用 `nano-banana-2`。如需最高画质的 4K 输出，使用 `nano-banana-pro`。
</Tip>

## 可用端点

| 端点                       | 方法   | 描述                     |
| ------------------------ | ---- | ---------------------- |
| `/gemini/image/generate` | POST | 使用 Nano Banana 生成或编辑图像 |
| `/gemini/task/result`    | GET  | 图像**与**视频共用的任务查询       |

***

### 浏览 API 文档

* [生成图像](image) —— 使用 Nano Banana 创建或编辑图像
* [获取任务结果](/zh/api-reference/gemini/task) —— 视频与图像共用查询

<Info>
  需要使用 Gemini 官方 SDK？查看 [Gemini 兼容接口](/zh/api-reference/gemini/compat-introduction)，可直接使用官方 **@google/genai** 库。
</Info>
