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

# Nano Banana 图像生成 API 文档

> 使用 Nano Banana API 通过文本提示生成高质量图像。

<Note>
  由于 Nano Banana 生图是同步响应，生成时间较长，建议使用 **[https://api.ttapi.org](https://api.ttapi.org)** 网关
</Note>

## 可用模型

| 模型                               | 别名                   |
| :------------------------------- | :------------------- |
| `gemini-2.5-flash-image`         | `Nano Banana`        |
| `gemini-2.5-flash-image-preview` | `Nano Banana`        |
| `gemini-3-pro-image-preview`     | `Nano Banana Pro`    |
| `gemini-3.1-flash-image-preview` | `Nano Banana 2`      |
| `gemini-3.1-flash-lite-image`    | `Nano Banana 2 Lite` |


## OpenAPI

````yaml openapi/cn/gemini.json POST /gemini/image/generate
openapi: 3.1.0
info:
  title: Gemini API DOCS
  version: 1.0.0
  description: TTAPI Gemini API 接口服务，包含 Nano Banana 图片生成和 Gemini 视频生成能力。
servers:
  - url: https://api.ttapi.org
security: []
paths:
  /gemini/image/generate:
    post:
      description: 根据文本和图像提示生成图像或修改图像。注意：非官方原格式对话式交互。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateRequest'
      responses:
        '200':
          $ref: '#/components/responses/SuccessResponse1'
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GenerateRequest:
      type: object
      properties:
        prompt:
          type: string
          description: 生成图像或修改图像描述词
        model:
          type: string
          description: 模型版本
          default: gemini-3-pro-image-preview
          enum:
            - gemini-2.5-flash-image-preview
            - gemini-2.5-flash-image
            - gemini-3-pro-image-preview
            - gemini-3.1-flash-image-preview
            - gemini-3.1-flash-lite-image
        refer_images:
          type: array
          description: 参考图像列表，支持多图，图像url和base64
          items:
            type: string
          example:
            - https://cdn.ttapi.io/xxx1.png
            - https://cdn.ttapi.io/xxx2.png
        aspect_ratio:
          type: string
          default: '1:1'
          enum:
            - '1:1'
            - '2:3'
            - '3:2'
            - '3:4'
            - '4:3'
            - '4:5'
            - '5:4'
            - '9:16'
            - '16:9'
            - '21:9'
            - '1:4'
            - '4:1'
            - '1:8'
            - '8:1'
          description: >-
            图片比例, 仅支持 gemini-3 及以上版本模型使用 <br/> 1:4、4:1、1:8、8:1 仅
            gemini-3.1-flash-image-preview 模型可用
        image_size:
          type: string
          default: 1K
          enum:
            - 1K
            - 2K
            - 4K
          description: 图片分辨率，**注意此处为大写的“K”**
        google_search:
          type: boolean
          description: |-
            是否启用谷歌网页搜索
            - false：禁用
            - true：启用
          default: 'false'
        image_search:
          type: boolean
          description: |-
            是否启用谷歌图片搜索
            - false：禁用
            - true：启用
          default: 'false'
        thinking_level:
          type: string
          description: 思考等级 <br/> 仅 **gemini-3.1-flash-image-preview** 模型可用
          enum:
            - Minimal
            - High
        sync_return:
          type: boolean
          default: 'true'
          description: 是否同步。 true-同步返回图像结果，接口等待耗时较长；  false-立马返回 jobId ，通过回调或查询获取图像结果。
        hook_url:
          type: string
          description: 回调通知地址
      required:
        - prompt
        - model
  responses:
    SuccessResponse1:
      description: 请求成功
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: SUCCESS
              message:
                type: string
                example: success
              data:
                type: object
                description: 任务结果
                properties:
                  prompt:
                    type: string
                    description: 提示词
                  refer_images:
                    type: array
                    description: 参考图像。有效期详见[存储与持久化](/grids/cn/faq/storage)
                  image_url:
                    type: string
                    description: 图片地址。有效期详见[存储与持久化](/grids/cn/faq/storage)
                  quota:
                    type: string
                    description: 消耗配额
            example:
              status: SUCCESS
              message: success
              data:
                prompt: a cute cat
                refer_images: null
                image_url: >-
                  https://cdn.ttapi.io/other/2025-09-10/8b46aa28-4433-455f-bf5c-f5ccea48baf2.png
                quota: 2
            required:
              - status
              - message
              - data
    400Response:
      description: 参数错误
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: 授权失败
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        请前往 <a href='https://dashboard.ttapi.io' target='_blank'>TTAPI 控制台</a>
        获取 API 密钥。

````