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

# Gemini Nano Banana 2.1 画像生成

> Gemini Nano Banana 2.1 の通常版と VIP で画像を生成します. 最大 14 枚の参照画像と 1K, 2K, 4K 解像度に対応します.

<Note>
  **中国本土のユーザー向け:** Base URL として `https://toapis.cn` を使用してください. 以下の例の `https://toapis.com` を `https://toapis.cn` に置き換えてください.
</Note>

## モデルの選択

| バージョン | Model ID |
| - | - |
| 通常版 | `gemini-nano-banana-2.1` |
| VIP | `gemini-nano-banana-2.1-vip` |

両モデルは同じエンドポイントとリクエストパラメータを使用します. `model` フィールドで切り替えてください. テキストからの画像生成と画像編集に対応します. リクエストは非同期で実行され, 送信後に返されるタスク ID で結果を取得できます.

<Warning>
  `image_urls` は公開アクセス可能な画像 URL のみを受け付けます. base64 データは使用できません. ローカル画像は先に [画像アップロード API](../../uploads/images) でアップロードして URL を取得してください.
</Warning>

## 認証

<ParamField header="Authorization" type="string" required>
  すべてのリクエストに Bearer Token が必要です. [API Key 管理ページ](https://toapis.com/console/token) から API Key を取得してください.

  ```text theme={null}
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## リクエストパラメータ

<ParamField body="model" type="string" default="gemini-nano-banana-2.1" required>
  モデル名. `gemini-nano-banana-2.1` または `gemini-nano-banana-2.1-vip` を使用します.
</ParamField>

<ParamField body="prompt" type="string" required>
  画像生成または編集のためのテキスト説明.
</ParamField>

<ParamField body="size" type="string">
  出力画像のアスペクト比. 対応する値:

  * `1:1`
  * `3:2`, `2:3`
  * `4:3`, `3:4`
  * `16:9`, `9:16`
  * `5:4`, `4:5`
  * `21:9`
  * `1:4`, `4:1`
  * `1:8`, `8:1`
</ParamField>

<ParamField body="n" type="integer" default={1}>
  出力枚数は数値の `1` に固定されています. 文字列の `"1"` は使用しないでください.
</ParamField>

<ParamField body="image_urls" type="string[]">
  画像生成や編集に使用する参照画像 URL の文字列配列. 最大 14 枚. 各 URL は公開アクセス可能である必要があります. 参照画像の枚数は出力画像の枚数ではありません.

  画像 1 枚につき最大 10MB. 対応形式: .jpeg, .jpg, .png, .webp.

  ```json theme={null}
  ["https://example.com/photo.jpg"]
  ```
</ParamField>

<ParamField body="metadata" type="object">
  追加の設定パラメータ.

  <Expandable title="metadata">
    <ParamField body="resolution" type="string" default="1K">
      出力画像の解像度. 対応する値: `1K`, `2K`, `4K`. デフォルトは `1K`. 大文字の `K` を使用してください.
    </ParamField>
  </Expandable>
</ParamField>

## レスポンスフィールド

<ResponseField name="id" type="string">
  状態と結果の取得に使用するタスク ID.
</ResponseField>

<ResponseField name="object" type="string">
  常に `generation.task`.
</ResponseField>

<ResponseField name="model" type="string">
  リクエストで使用したモデル ID.
</ResponseField>

<ResponseField name="status" type="string">
  タスクの状態: `queued`, `in_progress`, `completed`, `failed`.
</ResponseField>

<ResponseField name="progress" type="integer">
  タスクの進捗率. 0-100 の範囲.
</ResponseField>

<ResponseField name="created_at" type="integer">
  タスク作成時刻. 秒単位の Unix タイムスタンプ.
</ResponseField>

<ResponseField name="metadata" type="object">
  タスクのメタデータ.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://toapis.com/v1/images/generations \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "gemini-nano-banana-2.1",
    "prompt": "ネオンが輝くサイバーパンク風の都市の夜景",
    "size": "16:9",
    "n": 1,
    "metadata": {
      "resolution": "2K"
    }
  }'
  ```

  ```bash cURL (VIP 画像編集) theme={null}
  curl --request POST \
    --url https://toapis.com/v1/images/generations \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "gemini-nano-banana-2.1-vip",
    "prompt": "この写真を水彩画のスタイルに変換してください",
    "size": "1:1",
    "n": 1,
    "image_urls": [
      "https://example.com/photo.jpg"
    ],
    "metadata": {
      "resolution": "2K"
    }
  }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://toapis.com/v1/images/generations",
      headers={
          "Authorization": "Bearer YOUR_API_KEY",
          "Content-Type": "application/json"
      },
      json={
          "model": "gemini-nano-banana-2.1",
          "prompt": "ネオンが輝くサイバーパンク風の都市の夜景",
          "size": "16:9",
          "n": 1,
          "metadata": {
              "resolution": "2K"
          }
      }
  )
  response.raise_for_status()
  task = response.json()
  print(task["id"])
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://toapis.com/v1/images/generations', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      "model": "gemini-nano-banana-2.1",
      "prompt": "ネオンが輝くサイバーパンク風の都市の夜景",
      "size": "16:9",
      "n": 1,
      "metadata": {
        "resolution": "2K"
      }
    })
  });

  if (!response.ok) {
    throw new Error(await response.text());
  }
  const task = await response.json();
  console.log(task.id);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "task_img_abc123def456",
    "object": "generation.task",
    "model": "gemini-nano-banana-2.1",
    "status": "queued",
    "progress": 0,
    "created_at": 1703884800,
    "metadata": {}
  }
  ```
</ResponseExample>

## 結果の取得

送信レスポンスの `id` がタスク ID です. [画像タスク状態 API](../../tasks/image-status) で状態と最終画像を取得してください. 非同期通知については [タスク Webhook](../../webhooks/task-webhooks) を参照してください.


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