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

# Nano Banana 2

> Nano Banana 2 是 Google Gemini 图片系列的通用型生成与编辑模型，重点兼顾生成速度、指令理解、文字渲染和多张参考图下的主体一致性。



## OpenAPI

````yaml api-reference/openapi/nano-banana--nano-banana-2.zh.yaml POST /v1/images/generations
openapi: 3.1.0
info:
  title: Nano Banana 2 API
  version: 1.0.0
  description: >-
    Nano Banana 2 是 Google Gemini
    图片系列的通用型生成与编辑模型，重点兼顾生成速度、指令理解、文字渲染和多张参考图下的主体一致性。在 APIPod 中，公开模型 ID 为
    nano-banana-2，支持文生图、图片生成与编辑；接受文本、图片输入，并通过异步图片任务返回结果。
servers:
  - url: https://api.apipod.ai
    description: 生产环境
security: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Nano Banana 2
      summary: 创建生成任务
      description: >-
        Nano Banana 2 是 Google Gemini
        图片系列的通用型生成与编辑模型，重点兼顾生成速度、指令理解、文字渲染和多张参考图下的主体一致性。在 APIPod 中，公开模型 ID 为
        nano-banana-2，支持文生图、图片生成与编辑；接受文本、图片输入，并通过异步图片任务返回结果。
      operationId: create-nano-banana-nano-banana-2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              title: Nano Banana 2
              properties:
                model:
                  type: string
                  title: Model ID
                  description: APIPod 公开模型 ID。
                  const: nano-banana-2
                prompt:
                  type: string
                  title: Prompt
                  description: 生成或编辑指令。 最大字符串长度：3993。
                image_urls:
                  type: array
                  title: Input Images
                  items:
                    type: string
                  description: 可公开访问的源图片或参考图 URL。
                aspect_ratio:
                  type: string
                  title: Aspect Ratio
                  description: 输出宽高比。
                  enum:
                    - '1:1'
                    - '1:4'
                    - '1:8'
                    - '2:3'
                    - '3:2'
                    - '3:4'
                    - '4:1'
                    - '4:3'
                    - '4:5'
                    - '5:4'
                    - '8:1'
                    - '9:16'
                    - '16:9'
                    - '21:9'
                  default: '1:1'
                quality:
                  type: string
                  title: Quality
                  description: 输出质量或图片分辨率档位。
                  enum:
                    - 512px
                    - 1K
                    - 2K
                    - 4K
                  default: 1K
              required:
                - model
                - prompt
            example:
              model: nano-banana-2
              prompt: >-
                A premium product photograph on a dark studio set, precise
                typography, soft rim lighting, highly detailed.
              aspect_ratio: '1:1'
              quality: 1K
      responses:
        '200':
          description: 任务已受理
          content:
            application/json:
              schema:
                type: object
                title: Task Submit Response
                description: Standard response for task submission
                properties:
                  code:
                    type: integer
                    description: HTTP 状态码。
                  data:
                    type: object
                    title: Task Submit Data
                    description: 响应数据。
                    properties:
                      task_id:
                        type: string
                        description: 用于查询任务状态的 APIPod 任务 ID。
                  message:
                    type: string
                    description: 响应消息。
                required:
                  - code
                  - message
                  - data
              example:
                code: 200
                message: success
                data:
                  task_id: img_task_01JEXAMPLE
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |-
            curl https://api.apipod.ai/v1/images/generations \
              -H "Authorization: Bearer $APIPOD_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
              "model": "nano-banana-2",
              "prompt": "A premium product photograph on a dark studio set, precise typography, soft rim lighting, highly detailed.",
              "aspect_ratio": "1:1",
              "quality": "1K"
            }'
        - lang: Python
          label: Python
          source: |-
            import os
            import requests

            payload = {
              "model": "nano-banana-2",
              "prompt": "A premium product photograph on a dark studio set, precise typography, soft rim lighting, highly detailed.",
              "aspect_ratio": "1:1",
              "quality": "1K"
            }

            response = requests.post(
                "https://api.apipod.ai/v1/images/generations",
                headers={
                    "Authorization": f"Bearer {os.environ['APIPOD_API_KEY']}",
                    "Content-Type": "application/json",
                },
                json=payload,
                timeout=60,
            )
            response.raise_for_status()
            print(response.json())
        - lang: Go
          label: Go
          source: |-
            package main

            import (
                "bytes"
                "encoding/json"
                "fmt"
                "net/http"
                "os"
            )

            func main() {
                payload := map[string]any{}
                if err := json.Unmarshal([]byte(`{
              "model": "nano-banana-2",
              "prompt": "A premium product photograph on a dark studio set, precise typography, soft rim lighting, highly detailed.",
              "aspect_ratio": "1:1",
              "quality": "1K"
            }`), &payload); err != nil {
                    panic(err)
                }
                body, err := json.Marshal(payload)
                if err != nil {
                    panic(err)
                }

                req, err := http.NewRequest(http.MethodPost, "https://api.apipod.ai/v1/images/generations", bytes.NewReader(body))
                if err != nil {
                    panic(err)
                }
                req.Header.Set("Authorization", "Bearer "+os.Getenv("APIPOD_API_KEY"))
                req.Header.Set("Content-Type", "application/json")

                resp, err := http.DefaultClient.Do(req)
                if err != nil {
                    panic(err)
                }
                defer resp.Body.Close()
                fmt.Println(resp.Status)
            }
        - lang: Rust
          label: Rust
          source: |-
            use reqwest::Client;
            use serde_json::json;
            use std::env;

            #[tokio::main]
            async fn main() -> Result<(), Box<dyn std::error::Error>> {
                let payload = json!({
              "model": "nano-banana-2",
              "prompt": "A premium product photograph on a dark studio set, precise typography, soft rim lighting, highly detailed.",
              "aspect_ratio": "1:1",
              "quality": "1K"
            });
                let response = Client::new()
                    .post("https://api.apipod.ai/v1/images/generations")
                    .bearer_auth(env::var("APIPOD_API_KEY")?)
                    .json(&payload)
                    .send()
                    .await?
                    .error_for_status()?;

                println!("{}", response.text().await?);
                Ok(())
            }
        - lang: JavaScript
          label: JavaScript
          source: >-
            const response = await
            fetch("https://api.apipod.ai/v1/images/generations", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.APIPOD_API_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify(
              {
                "model": "nano-banana-2",
                "prompt": "A premium product photograph on a dark studio set, precise typography, soft rim lighting, highly detailed.",
                "aspect_ratio": "1:1",
                "quality": "1K"
              }
              ),
            });


            if (!response.ok) {
              throw new Error(`APIPod request failed: ${response.status} ${await response.text()}`);
            }


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: APIPod API key
      description: 在 Authorization 请求头中使用 Bearer APIPod_API_KEY。

````