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

# 概述

> Gemini 生图概述：Generations、原生格式、Chat 生图（文生图/图生图），香蕉 2.1 PDF/短视频参考与 Thinking 档位。

# Gemini绘图概述

Omniall AI 上 Gemini 图像模型常见调用方式：

| 菜单 | 路径 | 说明 |
| - | - | - |
| Generations | `POST /v1/images/generations` | OpenAI Images 通用入口 |
| Gemini原生格式 | `POST /v1beta/models/{model}:generateContent` | 原生 `responseModalities` + `imageConfig`；支持图片 / PDF / 短视频 `inlineData` |
| Chat 生图 | `POST /v1/chat/completions` | 同一 Chat 接口：文生图 / 图生图 / 多图参考；香蕉 2.1 还可 `file`（PDF）、`video_url`（短视频） |

画幅 / 分辨率可通过 `extra_body.google.image_config`（Chat）或 `generationConfig.imageConfig`（原生）设置，例如 `aspect_ratio` / `aspectRatio`、`image_size` / `imageSize`（`1K` / `2K` / `4K`）。

`model` 以[模型广场](https://omniall.ai/pricing)为准。

## 香蕉 2.1（`gemini-nano-banana-2.1`）

支持文生图、图生图，以及 **PDF 参考**、**短视频参考** 生图。

| 形态 | 参考输入 | 说明 |
| - | - | - |
| 原生 `generateContent` | `parts[].inlineData` | `mimeType`：`image/*`、`application/pdf`、`video/mp4`；`data` 为原始 Base64（无 `data:` 前缀） |
| Chat Completions | `image_url` / `file` / `video_url` | 网关下载 URL 或解码 data URL → 转成上游 `inlineData`；**支持 PDF URL、视频 URL** |

### Chat：PDF URL

```json theme={null}
{
  "model": "gemini-nano-banana-2.1",
  "stream": false,
  "extra_body": {
    "google": {
      "image_config": { "aspect_ratio": "3:2", "image_size": "1K" }
    }
  },
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "读取该 PDF，按页列出信息后生成白底参考图。" },
      {
        "type": "file",
        "file": {
          "filename": "reference.pdf",
          "file_data": "https://example.com/reference.pdf"
        }
      }
    ]
  }]
}
```

### Chat：视频 URL

```json theme={null}
{
  "model": "gemini-nano-banana-2.1",
  "stream": false,
  "extra_body": {
    "google": {
      "image_config": { "aspect_ratio": "3:2", "image_size": "1K" }
    }
  },
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "观看视频，按场景顺序生成参考图。" },
      { "type": "video_url", "video_url": "https://example.com/clip.mp4" }
    ]
  }]
}
```

注意：

* `video_url` 请传**字符串**，不要写成 `{ "url": "..." }`
* `file` 须同时提供 `filename` 与 `file_data`
* URL 须公网可下载；单文件下载默认约 64MB；优先短小 MP4 / 小 PDF
* 完整 curl / 原生生图示例见 [Gemini原生格式](/zh-CN/api-reference/endpoints/gemini-native-image) 与 [Chat 生图](/zh-CN/api-reference/endpoints/gemini-chat-image)

### 可选：Thinking（思考档位）

`gemini-nano-banana-2.1` 支持官方 Thinking 能力。常规接入可**省略**配置，使用默认档位即可。

| 档位 | 说明 |
| - | - |
| `minimal` | 较低延迟，思考量较少 |
| `medium` | 默认档位 |
| `high` | 增加思考量；效果仍取决于具体任务 |

| 字段 | 作用 |
| - | - |
| `thinkingLevel` / `thinking_level` | 思考档位（上表三档） |
| `includeThoughts` / `include_thoughts` | 是否在响应中返回思考内容；**不会关闭**模型内部思考 |

用量回包中可能出现 `reasoning_tokens` / `thoughtsTokenCount`，表示思考消耗，与是否返回思考正文无关。

**原生** — 写在 `generationConfig.thinkingConfig`：

```json theme={null}
{
  "generationConfig": {
    "responseModalities": ["TEXT", "IMAGE"],
    "imageConfig": { "imageSize": "1K", "aspectRatio": "3:2" },
    "thinkingConfig": {
      "thinkingLevel": "high",
      "includeThoughts": false
    }
  }
}
```

**Chat** — 写在 `extra_body.google.thinking_config`（须用 snake\_case）：

```json theme={null}
{
  "model": "gemini-nano-banana-2.1",
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "观看视频，生成角色一致的参考图。" },
      { "type": "video_url", "video_url": "https://example.com/clip.mp4" }
    ]
  }],
  "extra_body": {
    "google": {
      "image_config": { "aspect_ratio": "16:9", "image_size": "1K" },
      "thinking_config": {
        "thinking_level": "high",
        "include_thoughts": false
      }
    }
  }
}
```

注意：Chat 请使用 `thinking_config` / `thinking_level`，不要写 `thinkingConfig`（camelCase 会报错）。解析响应时请遍历全部 `parts`，跳过 `thought: true` 项后再取图片。

其他模型示例：`gemini-3.1-flash-image-preview`、`gemini-3-pro-image-preview`（以模型广场开通为准）。


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