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

# Nano Banana 2

> Nano Banana 2 是 Google 最新的图像生成模型，基于 Gemini 3.1 Flash Image 构建。它是 Nano Banana Pro 的高效版本，面向速度和高并发使用场景优化，同时仍能生成高保真图像。

## 模型选择

<Tip>
  此接口同时支持 `google/nano-banana-2` 和 `google/nano-banana-2-v2`。

  `v2` 版本价格约低 40%，但生成速度可能更慢。请根据成本和延迟需求选择合适版本。
  `google_search` 和 `output_format` 在 `v2` 上不受支持，传入后可能会被忽略。
</Tip>

## 查询任务状态

提交任务后，请使用统一查询接口查看进度并获取结果：

<Card title="获取任务信息" icon="magnifying-glass" href="/zh/models/common/get-task-info">
  了解如何查询任务状态并获取生成结果
</Card>

<Tip>
  生产环境中，建议使用 `callback_url` 参数接收任务完成后的自动通知，而不是轮询状态接口。
</Tip>

## 相关资源

<CardGroup cols={2}>
  <Card title="模型概览" icon="store" href="/zh/models/quickstart">
    查看所有可用模型
  </Card>

  <Card title="通用 API" icon="gear" href="/zh/common-api/get-account-credits">
    查询账户剩余积分
  </Card>
</CardGroup>


## OpenAPI

````yaml zh/models/google/nano-banana-2.json post /api/v1/client/job/CreateTask
openapi: 3.0.0
info:
  title: Google Nano Banana 2 API
  description: crun.ai Nano Banana 2 API 文档
  version: 1.0.0
  contact:
    name: Technical Support
    email: support@crun.ai
servers:
  - url: https://api.crun.ai
    description: API 服务器
security:
  - ApiKeyAuth: []
paths:
  /api/v1/client/job/CreateTask:
    post:
      summary: 使用 Google Nano Banana 2 生成图像
      operationId: google/nano-banana-2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  enum:
                    - google/nano-banana-2
                    - google/nano-banana-2-v2
                  description: |-
                    用于生成的模型名称，必填。

                    - 支持 `google/nano-banana-2`
                    - 支持 `google/nano-banana-2-v2`
                callback_url:
                  type: string
                  format: uri
                  description: |-
                    可选。用于接收任务完成通知的回调 URL。

                    - 生成完成后，系统会向该 URL POST 任务状态和结果
                    - 回调 payload 结构与任务状态查询接口返回的 `data` 对象一致
                    - 您的回调接口应支持接收包含结果的 JSON POST 请求
                    - 成功接收后应返回 HTTP 200 状态码
                  example: https://your-domain.com/api/callback
                input:
                  type: object
                  description: |-
                    Google Nano Banana 2 的输入参数。支持极端宽高比、超长提示词和多图组合。

                    `google/nano-banana-2-v2` 的参数兼容性说明：
                    - 不支持 `google_search`，该参数可能会被忽略。
                    - 不支持 `output_format`，该参数可能会被忽略。
                  properties:
                    prompt:
                      type: string
                      description: 图像的详细描述。最多支持 20,000 个字符，适合复杂场景编排。
                      minLength: 1
                      maxLength: 20000
                      example: >-
                        A panoramic 8:1 scroll showing the history of human
                        civilization from the stone age to a far-future space
                        colony, rendered in a continuous, flowing oil painting
                        style.
                    img_urls:
                      type: array
                      description: 输入图片 URL，可用于图生图、编辑或多图组合。最多支持 14 张图片。
                      items:
                        type: string
                        format: uri
                      maxItems: 14
                      example:
                        - https://example.com/subject.jpg
                        - https://example.com/style-ref.png
                    resolution:
                      type: string
                      description: 输出图像分辨率质量。
                      enum:
                        - 1K
                        - 2K
                        - 4K
                      default: 1K
                      example: 4K
                    aspect_ratio:
                      type: string
                      description: 图像宽高比。`auto` 会匹配输入图片；也支持电影感和横幅等极端比例。
                      enum:
                        - '1:1'
                        - '2:3'
                        - '3:2'
                        - '3:4'
                        - '4:3'
                        - '4:5'
                        - '5:4'
                        - '9:16'
                        - '16:9'
                        - '1:4'
                        - '4:1'
                        - '1:8'
                        - '8:1'
                        - '21:9'
                        - auto
                      default: '1:1'
                      example: '21:9'
                    google_search:
                      type: boolean
                      description: >-
                        是否使用 Google
                        Search，让提示词参考真实世界视觉信息或当前趋势。`google/nano-banana-2-v2`
                        不支持该参数，可能会被忽略。
                      default: false
                      example: true
                    output_format:
                      type: string
                      description: 输出图像文件格式。`google/nano-banana-2-v2` 不支持该参数，可能会被忽略。
                      enum:
                        - png
                        - jpg
                      default: png
                  required:
                    - prompt
            example:
              model: google/nano-banana-2-v2
              input:
                prompt: >-
                  Combine the architectural style of image 1, the character from
                  image 2, and the lighting from image 3 into a seamless 4K
                  composition.
                img_urls:
                  - https://example.com/gothic-cathedral.jpg
                  - https://example.com/cyberpunk-hacker.png
                  - https://example.com/sunset-lighting-ref.webp
                resolution: 4K
                aspect_ratio: auto
      responses:
        '200':
          description: 请求成功
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      data:
                        type: object
                        properties:
                          task_id:
                            type: string
                            description: 任务 ID，可用于通过任务详情接口查询任务状态
                            example: task_nano-banana-pro_1765166238715
              example:
                code: 200
                message: success
                data:
                  task_id: task_nano-banana-2_12345678
        '422':
          description: 参数校验错误
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResponse'
                  - type: object
                    properties:
                      errors:
                        type: array
                        description: 详细的参数校验错误信息
                        items:
                          type: string
                        example:
                          - >-
                            Value error, Invalid input for model
                            google/nano-banana-2: output_format: Input should be
                            'png' or 'jpg'
              example:
                code: 422
                message: Missing Params or Type Error
                errors:
                  - >-
                    Value error, Invalid input for model google/nano-banana-2:
                    output_format: Input should be 'png' or 'jpg'
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    ApiResponse:
      type: object
      properties:
        code:
          type: integer
          enum:
            - 200
            - 401
            - 402
            - 404
            - 422
            - 429
            - 455
            - 500
            - 501
            - 505
          description: |-
            响应状态码

            - **200**：成功，请求已成功处理
            - **401**：未授权，身份验证凭证缺失或无效
            - **402**：积分不足，账户积分不足以执行本次操作
            - **404**：未找到，请求的资源或接口不存在
            - **422**：参数校验错误，请求参数未通过校验
            - **429**：触发速率限制，请求频率已超过当前资源限制
            - **455**：服务不可用，系统正在维护
            - **500**：服务器错误，处理请求时发生意外错误
            - **501**：生成失败，内容生成任务失败
            - **505**：功能已禁用，请求的功能当前不可用
        message:
          type: string
          description: 响应消息；失败时为错误说明
          example: success
  responses:
    Error:
      description: 服务器错误
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: |-
        所有 API 都需要通过 API Key 进行身份验证。

        获取 API Key：
        1. 访问 [API Key 管理页面](https://crun.ai/zh/user-api-key) 获取您的 API Key

        使用方式：
        添加到请求头：

        x-api-key: YOUR_API_KEY

        注意：
        - 请妥善保管您的 API Key，不要与他人共享
        - 如果怀疑 API Key 已泄露，请立即在管理页面重置

````