> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-claude-comfy-concurrency-limits-page-s84u33.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Google Gemini を使用する

> Comfy Router 経由で HTTP を使って Google Gemini のテキストモデルを呼び出すための Python、TypeScript、cURL スニペット、およびリクエストフィールドと結果の形状

Google Gemini の API リファレンス。Google Gemini は Google のマルチモーダルテキストモデル群で、Flash および Pro の各ティアにわたり、高速なドラフト作成から深い推論までをカバーします。

## クイックスタート

[あなたの Comfy ワークスペース](https://platform.comfy.org/profile/api-keys?onboarding=router) でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK (`pip install comfy-sdk` および `npm install @comfyorg/sdk`) を使用します。cURL スニペットは raw HTTP 経由で同じ呼び出しを行います。

呼び出したいモデルを選択してください。モデルは 1 つのリクエストとレスポンスの形状を共有しており、以下で一度だけ説明します。

<Tabs>
  <Tab title="Gemini 3.1 Pro">
    **モデル ID:** `vertexai/gemini-3.1-pro-preview`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview`

    <Tabs defaultTabIndex={1}>
      <Tab title="結果を待つ">
        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # The SDK automatically creates an idempotency key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  result = await client.models.run(
                      "vertexai/gemini-3.1-pro-preview",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // The SDK automatically creates an idempotency key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const result = await comfy.models.run<Result>("vertexai/gemini-3.1-pro-preview", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="キューに送信して後で収集する">
        同じ本文を `POST https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集について順を追って説明します。

        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  handle = await client.models.submit(
                      "vertexai/gemini-3.1-pro-preview",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )
                  print("request_id:", handle.request_id)  # with the model ID, all another process needs

                  # Poll until the request completes, waiting the Retry-After the server names.
                  async for update in handle.iter_events():
                      print(update.status, update.queue_position)

                  # The provider's own payload, the same value models.run() returns.
                  # A request that failed or was cancelled raises the typed Router error here.
                  result = await handle.get()

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const handle = await comfy.models.submit<Result>("vertexai/gemini-3.1-pro-preview", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          console.log("requestId:", handle.requestId); // with the model ID, all another process needs

          // Poll until the request completes, waiting the Retry-After the server names.
          for await (const update of handle.events()) {
            console.log(update.status, update.queuePosition);
          }

          // The same result models.run() returns. A request that failed or was cancelled rejects here.
          const result = await handle.get();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"

          # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
          REQUEST_ID="<request_id from the 201 body>"
          curl -i https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests/$REQUEST_ID/status \
            -H "X-API-Key: $COMFY_API_KEY"

          # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.1-pro-preview/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Gemini 3.5 Flash">
    **モデル ID:** `vertexai/gemini-3.5-flash`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash`

    <Tabs defaultTabIndex={1}>
      <Tab title="結果を待つ">
        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # The SDK automatically creates an idempotency key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  result = await client.models.run(
                      "vertexai/gemini-3.5-flash",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // The SDK automatically creates an idempotency key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const result = await comfy.models.run<Result>("vertexai/gemini-3.5-flash", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="キューに送信して後で収集する">
        同じ本文を `POST https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集について順を追って説明します。

        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  handle = await client.models.submit(
                      "vertexai/gemini-3.5-flash",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )
                  print("request_id:", handle.request_id)  # with the model ID, all another process needs

                  # Poll until the request completes, waiting the Retry-After the server names.
                  async for update in handle.iter_events():
                      print(update.status, update.queue_position)

                  # The provider's own payload, the same value models.run() returns.
                  # A request that failed or was cancelled raises the typed Router error here.
                  result = await handle.get()

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const handle = await comfy.models.submit<Result>("vertexai/gemini-3.5-flash", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          console.log("requestId:", handle.requestId); // with the model ID, all another process needs

          // Poll until the request completes, waiting the Retry-After the server names.
          for await (const update of handle.events()) {
            console.log(update.status, update.queuePosition);
          }

          // The same result models.run() returns. A request that failed or was cancelled rejects here.
          const result = await handle.get();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"

          # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
          REQUEST_ID="<request_id from the 201 body>"
          curl -i https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests/$REQUEST_ID/status \
            -H "X-API-Key: $COMFY_API_KEY"

          # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
          curl https://api.comfy.org/v2/models/vertexai/gemini-3.5-flash/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Gemini 2.5 Pro">
    **モデル ID:** `vertexai/gemini-2.5-pro`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro`

    <Tabs defaultTabIndex={1}>
      <Tab title="結果を待つ">
        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # The SDK automatically creates an idempotency key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  result = await client.models.run(
                      "vertexai/gemini-2.5-pro",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // The SDK automatically creates an idempotency key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const result = await comfy.models.run<Result>("vertexai/gemini-2.5-pro", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="キューに送信して後で収集する">
        同じ本文を `POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集について順を追って説明します。

        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  handle = await client.models.submit(
                      "vertexai/gemini-2.5-pro",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )
                  print("request_id:", handle.request_id)  # with the model ID, all another process needs

                  # Poll until the request completes, waiting the Retry-After the server names.
                  async for update in handle.iter_events():
                      print(update.status, update.queue_position)

                  # The provider's own payload, the same value models.run() returns.
                  # A request that failed or was cancelled raises the typed Router error here.
                  result = await handle.get()

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const handle = await comfy.models.submit<Result>("vertexai/gemini-2.5-pro", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          console.log("requestId:", handle.requestId); // with the model ID, all another process needs

          // Poll until the request completes, waiting the Retry-After the server names.
          for await (const update of handle.events()) {
            console.log(update.status, update.queuePosition);
          }

          // The same result models.run() returns. A request that failed or was cancelled rejects here.
          const result = await handle.get();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"

          # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
          REQUEST_ID="<request_id from the 201 body>"
          curl -i https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests/$REQUEST_ID/status \
            -H "X-API-Key: $COMFY_API_KEY"

          # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-pro/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Gemini 2.5 Flash">
    **モデル ID:** `vertexai/gemini-2.5-flash`

    **エンドポイント:** `POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash`

    <Tabs defaultTabIndex={1}>
      <Tab title="結果を待つ">
        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # The SDK automatically creates an idempotency key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  result = await client.models.run(
                      "vertexai/gemini-2.5-flash",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // The SDK automatically creates an idempotency key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const result = await comfy.models.run<Result>("vertexai/gemini-2.5-flash", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"
          ```
        </CodeGroup>
      </Tab>

      <Tab title="キューに送信して後で収集する">
        同じ本文を `POST https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests` に送信します。Router は実行が受け付けられるとすぐに `201` と `request_id` を返し、結果は準備が整い次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集について順を追って説明します。

        <CodeGroup>
          ```python Python theme={null}
          import asyncio
          from comfy_sdk import AsyncComfy

          # Reads COMFY_API_KEY from the environment.
          # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          async def main():
              async with AsyncComfy() as client:
                  handle = await client.models.submit(
                      "vertexai/gemini-2.5-flash",
                      {
                          "contents": [
                              {
                                  "role": "user",
                                  "parts": [
                                      {
                                          "text": "Describe a single red maple leaf on a white background in one sentence.",
                                      },
                                  ],
                              },
                          ],
                          "generationConfig": {
                              "temperature": 0.7,
                              "maxOutputTokens": 256,
                          },
                      },
                  )
                  print("request_id:", handle.request_id)  # with the model ID, all another process needs

                  # Poll until the request completes, waiting the Retry-After the server names.
                  async for update in handle.iter_events():
                      print(update.status, update.queue_position)

                  # The provider's own payload, the same value models.run() returns.
                  # A request that failed or was cancelled raises the typed Router error here.
                  result = await handle.get()

              print("text:", result["candidates"][0]["content"]["parts"][0]["text"])

          asyncio.run(main())
          ```

          ```typescript TypeScript theme={null}
          import { comfy } from "@comfyorg/sdk";

          // Reads COMFY_API_KEY from the environment.
          // Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
          type Result = { candidates: { content: { parts: { text: string }[] } }[] };
          const handle = await comfy.models.submit<Result>("vertexai/gemini-2.5-flash", {
            contents: [
              {
                role: "user",
                parts: [
                  {
                    text: "Describe a single red maple leaf on a white background in one sentence.",
                  },
                ],
              },
            ],
            generationConfig: {
              temperature: 0.7,
              maxOutputTokens: 256,
            },
          });
          console.log("requestId:", handle.requestId); // with the model ID, all another process needs

          // Poll until the request completes, waiting the Retry-After the server names.
          for await (const update of handle.events()) {
            console.log(update.status, update.queuePosition);
          }

          // The same result models.run() returns. A request that failed or was cancelled rejects here.
          const result = await handle.get();
          if (result.kind !== "json") throw new Error("expected a JSON result");

          console.log("text:", result.data.candidates[0].content.parts[0].text);
          ```

          ```bash cURL theme={null}
          # 1. Submit. Router answers 201 with request_id, status_url, response_url and cancel_url.
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests \
            -H "X-API-Key: $COMFY_API_KEY" \
            -H "Idempotency-Key: $(uuidgen)" \
            -H "Content-Type: application/json" \
            -d "{\"contents\": [{\"role\":\"user\",\"parts\":[{\"text\":\"Describe a single red maple leaf on a white background in one sentence.\"}]}], \"generationConfig\": {\"temperature\":0.7,\"maxOutputTokens\":256}}"

          # 2. Poll until status is COMPLETED, waiting the Retry-After seconds each response names.
          REQUEST_ID="<request_id from the 201 body>"
          curl -i https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests/$REQUEST_ID/status \
            -H "X-API-Key: $COMFY_API_KEY"

          # 3. Collect. 200 with the model's native output, 202 with the status body while it is still running.
          curl https://api.comfy.org/v2/models/vertexai/gemini-2.5-flash/requests/$REQUEST_ID \
            -H "X-API-Key: $COMFY_API_KEY"
          ```
        </CodeGroup>
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="contents" type="object[]" required>
  モデルとの現在の会話のコンテンツ。単一ターンのクエリでは単一のインスタンスです。マルチターンのクエリでは、会話履歴と最新のリクエストを含む繰り返しフィールドです。
</ParamField>

<ParamField body="contents[].parts" type="object[]" required />

<ParamField body="contents[].parts[].fileData" type="object">
  URI ベースのデータ。
</ParamField>

<ParamField body="contents[].parts[].fileData.fileUri" type="string">
  URI
</ParamField>

<ParamField body="contents[].parts[].fileData.mimeType" type="string">
  data フィールドまたは fileUri フィールドで指定されたファイルのメディアタイプ。許容される値は次のとおりです。gemini-2.0-flash-lite および gemini-2.0-flash では、オーディオファイルの最大長は 8.4 時間、ビデオファイル（音声なし）の最大長は 1 時間です。詳細については、Gemini のオーディオとビデオの要件を参照してください。テキストファイルは UTF-8 でエンコードされている必要があります。テキストファイルの内容はトークン制限にカウントされます。画像の解像度に制限はありません。

  指定可能な値: `application/pdf`, `audio/mpeg`, `audio/mp3`, `audio/wav`, `image/png`, `image/jpeg`, `image/webp`, `text/plain`, `video/mov`, `video/mpeg`, `video/mp4`, `video/mpg`, `video/avi`, `video/wmv`, `video/mpegps`, `video/flv`, `image/heic`, `image/heif`, `audio/flac`, `video/webm`
</ParamField>

<ParamField body="contents[].parts[].inlineData" type="object">
  生バイトのインラインデータ。gemini-2.0-flash-lite および gemini-2.0-flash では、inlineData を使用して最大 3000 枚の画像を指定できます。
</ParamField>

<ParamField body="contents[].parts[].inlineData.data" type="string (byte)">
  プロンプトにインラインで含める画像、PDF、またはビデオの base64 エンコーディング。メディアをインラインで含める場合は、データのメディアタイプ（mimeType）も指定する必要があります。サイズ制限: 20MB

  形式: `byte`
</ParamField>

<ParamField body="contents[].parts[].inlineData.mimeType" type="string">
  data フィールドまたは fileUri フィールドで指定されたファイルのメディアタイプ。許容される値は次のとおりです。gemini-2.0-flash-lite および gemini-2.0-flash では、オーディオファイルの最大長は 8.4 時間、ビデオファイル（音声なし）の最大長は 1 時間です。詳細については、Gemini のオーディオとビデオの要件を参照してください。テキストファイルは UTF-8 でエンコードされている必要があります。テキストファイルの内容はトークン制限にカウントされます。画像の解像度に制限はありません。

  指定可能な値: `application/pdf`, `audio/mpeg`, `audio/mp3`, `audio/wav`, `image/png`, `image/jpeg`, `image/webp`, `text/plain`, `video/mov`, `video/mpeg`, `video/mp4`, `video/mpg`, `video/avi`, `video/wmv`, `video/mpegps`, `video/flv`, `image/heic`, `image/heif`, `audio/flac`, `video/webm`
</ParamField>

<ParamField body="contents[].parts[].mediaProcessing" type="string">
  モデルがこのパートのビデオをどのように読み取るか。`"AGENTIC"` を設定すると、固定レートのフレームサンプリングではなく、モデルが検査するセグメントを判断します。省略すると、デフォルトの固定レートサンプリングになります。gemini-3.7-flash 以降の Flash モデルでサポートされています。
</ParamField>

<ParamField body="contents[].parts[].text" type="string">
  テキストプロンプトまたはコードスニペット。
</ParamField>

<ParamField body="contents[].parts[].thought" type="boolean">
  このパートがモデルからの思考/推論ステップであることを示します。
</ParamField>

<ParamField body="contents[].role" type="string">
  指定可能な値: `user`, `model`
</ParamField>

<ParamField body="generationConfig" type="object">
  生成のサンプリング、長さ、出力の設定。すべてのフィールドは任意です。以下で `default` を宣言しているフィールドは省略時にその値が適用され、それ以外はモデル自身の動作にフォールバックします。
</ParamField>

<ParamField body="generationConfig.imageConfig" type="object">
  画像生成の設定
</ParamField>

<ParamField body="generationConfig.imageConfig.aspectRatio" type="string">
  生成された画像のアスペクト比
</ParamField>

<ParamField body="generationConfig.imageConfig.imageOutputOptions" type="object">
  任意。生成された画像の画像出力形式。
</ParamField>

<ParamField body="generationConfig.imageConfig.imageOutputOptions.compressionQuality" type="integer">
  任意。出力画像の圧縮品質。
</ParamField>

<ParamField body="generationConfig.imageConfig.imageOutputOptions.mimeType" type="string">
  任意。出力を保存する画像形式（Vertex AI のパス、つまり Comfy 独自の認証情報で処理されるリクエスト、および GCP サービスアカウントで認証された BYOK リクエストの場合）。そこで受け付けられる値は `image/png` と `image/jpeg` で、大文字小文字を区別せずに照合され、リクエストが転送される前に小文字に正規化されます。それ以外の値は、このフィールド名を示す 400 で拒否されます。省略時は `image/png` がデフォルトです。Google AI Studio の APIキーで認証された BYOK リクエストは例外です。そのアップストリームにはそのようなプロパティがなく、存在する場合は呼び出し全体を拒否するため、このフィールドは尊重も拒否もされずにリクエストから削除され、出力形式は AI Studio が選択したものになります。どのパスでも、送信した値を前提とせず、返されたレスポンスのパート（`inlineData.mimeType`、`uploadImagesToStorage` が設定されている場合は `fileData.mimeType`）からメディアタイプを読み取ってください。
</ParamField>

<ParamField body="generationConfig.imageConfig.imageSize" type="string">
  任意。生成された画像のサイズを指定します。サポートされる値は 1K、2K、4K です。指定しない場合、モデルはデフォルト値 1K を使用します。
</ParamField>

<ParamField body="generationConfig.maxOutputTokens" type="integer">
  レスポンスで生成できるトークンの最大数。1 トークンは約 4 文字です。100 トークンはおおよそ 60～80 語に相当します。

  範囲: `16` ～ `65536`
</ParamField>

<ParamField body="generationConfig.responseModalities" type="`TEXT`, `IMAGE`[]" />

<ParamField body="generationConfig.seed" type="integer">
  シードが特定の値に固定されている場合、モデルは繰り返しのリクエストに対して同じ応答を返すよう最善を尽くします。決定論的な出力は保証されません。また、temperature などのモデルやパラメータ設定を変更すると、同じシード値を使用していても応答にばらつきが生じることがあります。デフォルトでは、ランダムなシード値が使用されます。以下のモデルで利用可能です: gemini-2.5-flash, gemini-2.5-pro, gemini-2.5-flash-preview-04-1, gemini-2.5-pro-preview-05-0, gemini-2.0-flash-lite-00, gemini-2.0-flash-001
</ParamField>

<ParamField body="generationConfig.stopSequences" type="string[]" />

<ParamField body="generationConfig.temperature" type="number" default="1">
  temperature は応答生成中のサンプリングに使用されます。これは topP と topK が適用されるときに発生します。temperature はトークン選択におけるランダム性の度合いを制御します。低い temperature は、あまり自由奔放でない、あるいは創造的でない応答が求められるプロンプトに適しており、高い temperature はより多様または創造的な結果につながります。temperature が 0 の場合、常に最も確率の高いトークンが選択されます。この場合、特定のプロンプトに対する応答はほぼ決定論的になりますが、わずかなばらつきが生じる可能性はあります。モデルが返す応答が一般的すぎる場合、短すぎる場合、またはモデルがフォールバック応答を返す場合は、temperature を上げてみてください

  範囲: `0` から `2`

  形式: `float`
</ParamField>

<ParamField body="generationConfig.thinkingConfig" type="object">
  オプション。thinking 機能の設定です。thinking とは、モデルが複雑なタスクをより小さなステップに分解して、より高品質な応答を生成するプロセスです。
</ParamField>

<ParamField body="generationConfig.thinkingConfig.includeThoughts" type="boolean">
  オプション。true の場合、モデルは自身の思考を応答に含めます。
</ParamField>

<ParamField body="generationConfig.thinkingConfig.thinkingBudget" type="integer">
  オプション。モデルの thinking プロセスに割り当てるトークン予算です。モデルはこの予算内に収まるよう最善を尽くします。
</ParamField>

<ParamField body="generationConfig.thinkingConfig.thinkingLevel" type="string">
  オプション。モデルの thinking レベルです。

  指定可能な値: `THINKING_LEVEL_UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH`, `MINIMAL`
</ParamField>

<ParamField body="generationConfig.topK" type="integer" default="40">
  Top-K は、モデルが出力のためにトークンを選択する方法を変更します。top-K が 1 の場合、次に選択されるトークンは、モデルの語彙内のすべてのトークンの中で最も確率が高いものになります。top-K が 3 の場合、次に選択されるトークンは、temperature を使用して、最も確率の高い 3 個のトークンの中から選択されます。

  範囲: `1` から `…`
</ParamField>

<ParamField body="generationConfig.topP" type="number" default="0.95">
  指定した場合、nucleus サンプリングが使用されます。
  Top-P は、モデルが出力のためにトークンを選択する方法を変更します。トークンは、その確率の合計が top-P の値と等しくなるまで、最も確率の高いもの（top-K を参照）から最も低いものへと選択されます。たとえば、トークン A、B、C の確率がそれぞれ 0.3、0.2、0.1 で、top-P の値が 0.5 の場合、モデルは temperature を使用して A または B のいずれかを次のトークンとして選択し、C は候補から除外されます。
  ランダム性の少ない応答には低い値を、ランダム性の多い応答には高い値を指定してください。

  範囲: `0` から `1`

  形式: `float`
</ParamField>

<ParamField body="safetySettings" type="object[]">
  安全でないコンテンツをブロックするためのリクエストごとの設定です。GenerateContentResponse.candidates に適用されます。
</ParamField>

<ParamField body="safetySettings[].category" type="string" required>
  指定可能な値: `HARM_CATEGORY_SEXUALLY_EXPLICIT`, `HARM_CATEGORY_HATE_SPEECH`, `HARM_CATEGORY_HARASSMENT`, `HARM_CATEGORY_DANGEROUS_CONTENT`
</ParamField>

<ParamField body="safetySettings[].threshold" type="string" required>
  指定可能な値: `OFF`, `BLOCK_NONE`, `BLOCK_LOW_AND_ABOVE`, `BLOCK_MEDIUM_AND_ABOVE`, `BLOCK_ONLY_HIGH`
</ParamField>

<ParamField body="systemInstruction" type="object">
  モデルをより良いパフォーマンスへと導くための指示です。たとえば、「できるだけ簡潔に答えてください」や「応答に専門用語を使わないでください」などです。テキスト文字列はトークン上限にカウントされます。systemInstruction の role フィールドは無視され、モデルのパフォーマンスには影響しません。注: parts にはテキストのみを使用し、各 part の content は別々の段落にしてください。
</ParamField>

<ParamField body="systemInstruction.parts" type="object[]" required>
  1 つのメッセージを構成する、順序付けられた parts のリストです。part ごとに異なる IANA MIME タイプを持つ場合があります。最大トークン数や画像数など入力の制限については、Google のモデルページにあるモデル仕様を参照してください。
</ParamField>

<ParamField body="systemInstruction.parts[].text" type="string">
  テキストプロンプトまたはコードスニペット。
</ParamField>

<ParamField body="systemInstruction.role" type="string">
  メッセージを作成するエンティティの識別情報です。以下の値がサポートされています。user: メッセージが実在の人物によって送信されたことを示します。通常はユーザーが生成したメッセージです。model: メッセージがモデルによって生成されたことを示します。model の値は、マルチターンの会話中にモデルからのメッセージを会話に挿入するために使用されます。マルチターンでない会話では、このフィールドは空白のままにするか、未設定にすることができます。

  指定可能な値: `user`, `model`
</ParamField>

<ParamField body="tools" type="object[]">
  システムが、モデルの知識や範囲外のアクションまたは一連のアクションを実行するために外部システムとやり取りできるようにするコードです。Function calling を参照してください。
</ParamField>

<ParamField body="tools[].functionDeclarations" type="object[]" />

<ParamField body="tools[].functionDeclarations[].description" type="string" />

<ParamField body="tools[].functionDeclarations[].name" type="string" required />

<ParamField body="tools[].functionDeclarations[].parameters" type="object">
  関数パラメータの JSON スキーマ
</ParamField>

<ParamField body="uploadImagesToStorage" type="boolean">
  true の場合、生成済みの画像はクラウドストレージにアップロードされ、インラインの base64 データではなく署名付き URL として返されます。URL は 24 時間後に有効期限が切れます。
</ParamField>

<ParamField body="videoMetadata" type="object">
  ビデオ入力の場合、ビデオの開始オフセットと終了オフセットを Duration 形式で指定します。たとえば、1:00 から始まる 10 秒のクリップを指定するには、"startOffset": \{ "seconds": 60 } および "endOffset": \{ "seconds": 70 } を設定します。メタデータは、ビデオデータが inlineData または fileData で提示されている場合にのみ指定してください。
</ParamField>

<ParamField body="videoMetadata.endOffset" type="object">
  ビデオのタイムライン位置に対する再生時間のオフセットを表します。
</ParamField>

<ParamField body="videoMetadata.endOffset.nanos" type="integer">
  ナノ秒解像度での符号付き秒の小数部。小数部を持つ負の秒の値であっても、nanos の値は非負でなければなりません。

  Range: `0` to `999999999`
</ParamField>

<ParamField body="videoMetadata.endOffset.seconds" type="integer">
  時間幅の符号付き秒。 -315,576,000,000 から +315,576,000,000 まで（両端を含む）の範囲でなければなりません。

  Range: `-315576000000` to `315576000000`
</ParamField>

<ParamField body="videoMetadata.startOffset" type="object">
  ビデオのタイムライン位置に対する再生時間のオフセットを表します。
</ParamField>

<ParamField body="videoMetadata.startOffset.nanos" type="integer">
  ナノ秒解像度での符号付き秒の小数部。小数部を持つ負の秒の値であっても、nanos の値は非負でなければなりません。

  Range: `0` to `999999999`
</ParamField>

<ParamField body="videoMetadata.startOffset.seconds" type="integer">
  時間幅の符号付き秒。 -315,576,000,000 から +315,576,000,000 まで（両端を含む）の範囲でなければなりません。

  Range: `-315576000000` to `315576000000`
</ParamField>

このドキュメントは、Router が `GET /v2/models/vertexai/gemini-3.1-pro-preview/openapi.json` で提供するスキーマから生成されています。これは、リクエストがプロバイダーに到達する前に Router が呼び出しを検証する対象となる、同じドキュメントです。

### 出力

<ResponseField name="candidates" type="object[]" />

<ResponseField name="candidates[].citationMetadata" type="object" />

<ResponseField name="candidates[].citationMetadata.citations" type="object[]" />

<ResponseField name="candidates[].citationMetadata.citations[].authors" type="string[]" />

<ResponseField name="candidates[].citationMetadata.citations[].endIndex" type="integer" />

<ResponseField name="candidates[].citationMetadata.citations[].license" type="string" />

<ResponseField name="candidates[].citationMetadata.citations[].publicationDate" type="string (date)">
  形式: `date`
</ResponseField>

<ResponseField name="candidates[].citationMetadata.citations[].startIndex" type="integer" />

<ResponseField name="candidates[].citationMetadata.citations[].title" type="string" />

<ResponseField name="candidates[].citationMetadata.citations[].uri" type="string" />

<ResponseField name="candidates[].content" type="object">
  モデルとの現在の会話のコンテンツです。単一ターンのクエリでは単一のインスタンスになります。マルチターンのクエリでは、会話履歴と最新のリクエストを含む繰り返しフィールドになります。
</ResponseField>

<ResponseField name="candidates[].content.parts" type="object[]" required />

<ResponseField name="candidates[].content.parts[].fileData" type="object">
  URI ベースのデータ。
</ResponseField>

<ResponseField name="candidates[].content.parts[].fileData.fileUri" type="string">
  URI
</ResponseField>

<ResponseField name="candidates[].content.parts[].fileData.mimeType" type="string">
  data フィールドまたは fileUri フィールドで指定されたファイルのメディアタイプです。指定できる値は次のとおりです。gemini-2.0-flash-lite と gemini-2.0-flash では、オーディオファイルの最大長は 8.4 時間、ビデオファイル（オーディオなし）の最大長は 1 時間です。詳細については、Gemini のオーディオとビデオの要件を参照してください。テキストファイルは UTF-8 でエンコードされている必要があります。テキストファイルの内容はトークン上限にカウントされます。画像の解像度に制限はありません。

  指定できる値: `application/pdf`, `audio/mpeg`, `audio/mp3`, `audio/wav`, `image/png`, `image/jpeg`, `image/webp`, `text/plain`, `video/mov`, `video/mpeg`, `video/mp4`, `video/mpg`, `video/avi`, `video/wmv`, `video/mpegps`, `video/flv`, `image/heic`, `image/heif`, `audio/flac`, `video/webm`
</ResponseField>

<ResponseField name="candidates[].content.parts[].inlineData" type="object">
  生のバイトによるインラインデータ。gemini-2.0-flash-lite と gemini-2.0-flash では、inlineData を使用して最大 3000 枚の画像を指定できます。
</ResponseField>

<ResponseField name="candidates[].content.parts[].inlineData.data" type="string (byte)">
  プロンプトにインラインで含める画像、PDF、またはビデオの base64 エンコーディングです。メディアをインラインで含める場合は、そのデータのメディアタイプ（mimeType）も指定する必要があります。サイズ制限: 20MB

  形式: `byte`
</ResponseField>

<ResponseField name="candidates[].content.parts[].inlineData.mimeType" type="string">
  data フィールドまたは fileUri フィールドで指定されたファイルのメディアタイプです。指定できる値は次のとおりです。gemini-2.0-flash-lite と gemini-2.0-flash では、オーディオファイルの最大長は 8.4 時間、ビデオファイル（オーディオなし）の最大長は 1 時間です。詳細については、Gemini のオーディオとビデオの要件を参照してください。テキストファイルは UTF-8 でエンコードされている必要があります。テキストファイルの内容はトークン上限にカウントされます。画像の解像度に制限はありません。

  指定できる値: `application/pdf`, `audio/mpeg`, `audio/mp3`, `audio/wav`, `image/png`, `image/jpeg`, `image/webp`, `text/plain`, `video/mov`, `video/mpeg`, `video/mp4`, `video/mpg`, `video/avi`, `video/wmv`, `video/mpegps`, `video/flv`, `image/heic`, `image/heif`, `audio/flac`, `video/webm`
</ResponseField>

<ResponseField name="candidates[].content.parts[].mediaProcessing" type="string">
  モデルがこのパートのビデオをどのように読み取るかを指定します。固定レートのフレームサンプリングではなく、検査するセグメントをモデルに判断させるには "AGENTIC" を設定します。省略した場合は、デフォルトの固定レートサンプリングが使用されます。gemini-3.7-flash 以降の Flash モデルでサポートされています。
</ResponseField>

<ResponseField name="candidates[].content.parts[].text" type="string">
  テキストプロンプトまたはコードスニペット。
</ResponseField>

<ResponseField name="candidates[].content.parts[].thought" type="boolean">
  このパートがモデルによる思考/推論のステップであることを示します。
</ResponseField>

<ResponseField name="candidates[].content.role" type="string">
  指定できる値: `user`, `model`
</ResponseField>

<ResponseField name="candidates[].finishReason" type="string" />

<ResponseField name="candidates[].safetyRatings" type="object[]" />

<ResponseField name="candidates[].safetyRatings[].category" type="string">
  指定できる値: `HARM_CATEGORY_SEXUALLY_EXPLICIT`, `HARM_CATEGORY_HATE_SPEECH`, `HARM_CATEGORY_HARASSMENT`, `HARM_CATEGORY_DANGEROUS_CONTENT`
</ResponseField>

<ResponseField name="candidates[].safetyRatings[].probability" type="string">
  コンテンツが指定された安全性カテゴリに違反している確率

  指定できる値: `NEGLIGIBLE`, `LOW`, `MEDIUM`, `HIGH`, `UNKNOWN`
</ResponseField>

<ResponseField name="createTime" type="string">
  レスポンスが作成されたタイムスタンプ。
</ResponseField>

<ResponseField name="modelVersion" type="string">
  レスポンスの生成に使用されたモデルのバージョン。
</ResponseField>

<ResponseField name="promptFeedback" type="object" />

<ResponseField name="promptFeedback.blockReason" type="string" />

<ResponseField name="promptFeedback.blockReasonMessage" type="string" />

<ResponseField name="promptFeedback.safetyRatings" type="object[]" />

<ResponseField name="promptFeedback.safetyRatings[].category" type="string">
  指定可能な値: `HARM_CATEGORY_SEXUALLY_EXPLICIT`、`HARM_CATEGORY_HATE_SPEECH`、`HARM_CATEGORY_HARASSMENT`、`HARM_CATEGORY_DANGEROUS_CONTENT`
</ResponseField>

<ResponseField name="promptFeedback.safetyRatings[].probability" type="string">
  コンテンツが指定された安全性カテゴリに違反する確率

  指定可能な値: `NEGLIGIBLE`、`LOW`、`MEDIUM`、`HIGH`、`UNKNOWN`
</ResponseField>

<ResponseField name="responseId" type="string">
  応答の一意の識別子。
</ResponseField>

<ResponseField name="usageMetadata" type="object" />

<ResponseField name="usageMetadata.cachedContentTokenCount" type="integer">
  出力専用。入力内のキャッシュされた部分（キャッシュされたコンテンツ）のトークン数。
</ResponseField>

<ResponseField name="usageMetadata.candidatesTokenCount" type="integer">
  応答内のトークン数。
</ResponseField>

<ResponseField name="usageMetadata.candidatesTokensDetails" type="object[]">
  モダリティごとの候補トークンの内訳。
</ResponseField>

<ResponseField name="usageMetadata.candidatesTokensDetails[].modality" type="string">
  入力または出力コンテンツのモダリティの種類。

  指定可能な値: `MODALITY_UNSPECIFIED`、`TEXT`、`IMAGE`、`VIDEO`、`AUDIO`、`DOCUMENT`
</ResponseField>

<ResponseField name="usageMetadata.candidatesTokensDetails[].tokenCount" type="integer">
  指定されたモダリティのトークン数。
</ResponseField>

<ResponseField name="usageMetadata.promptTokenCount" type="integer">
  リクエスト内のトークン数。cachedContent が設定されている場合でも、これは有効なプロンプトの合計サイズであり、キャッシュされたコンテンツ内のトークン数も含まれます。
</ResponseField>

<ResponseField name="usageMetadata.promptTokensDetails" type="object[]">
  モダリティごとのプロンプトトークンの内訳。
</ResponseField>

<ResponseField name="usageMetadata.promptTokensDetails[].modality" type="string">
  入力または出力コンテンツのモダリティの種類。

  指定可能な値: `MODALITY_UNSPECIFIED`、`TEXT`、`IMAGE`、`VIDEO`、`AUDIO`、`DOCUMENT`
</ResponseField>

<ResponseField name="usageMetadata.promptTokensDetails[].tokenCount" type="integer">
  指定されたモダリティのトークン数。
</ResponseField>

<ResponseField name="usageMetadata.thoughtsTokenCount" type="integer">
  thoughts 出力に含まれるトークン数。
</ResponseField>

<ResponseField name="usageMetadata.toolUsePromptTokenCount" type="integer">
  ツール使用プロンプトに含まれるトークン数。
</ResponseField>

<ResponseField name="usageMetadata.toolUsePromptTokensDetails" type="object[]">
  モダリティごとのツール使用プロンプトトークンの内訳。
</ResponseField>

<ResponseField name="usageMetadata.toolUsePromptTokensDetails[].modality" type="string">
  入力または出力コンテンツのモダリティの種類。

  指定可能な値: `MODALITY_UNSPECIFIED`、`TEXT`、`IMAGE`、`VIDEO`、`AUDIO`、`DOCUMENT`
</ResponseField>

<ResponseField name="usageMetadata.toolUsePromptTokensDetails[].tokenCount" type="integer">
  指定されたモダリティのトークン数。
</ResponseField>

<ResponseField name="usageMetadata.totalTokenCount" type="integer">
  トークンの合計数（プロンプト + 候補）。
</ResponseField>

<ResponseField name="usageMetadata.trafficType" type="string">
  リクエストに使用されたトラフィックタイプ（例: PROVISIONED\_THROUGHPUT）。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Describe a single red maple leaf on a white background in one sentence."
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 256
  }
}
```

### 出力

```json theme={null}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "A single red maple leaf rests on a plain white background, its edges sharp and its color deep."
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 18,
    "candidatesTokenCount": 24
  }
}
```

## 出荷前の確認

SDK は `Idempotency-Key` を生成し、自動リトライで再利用します。手動リトライでは元のキーを再利用してください。Router は最大 10 分間接続を保持できます。

リクエストが失敗すると、Router は理由を説明する `X-Comfy-Error-Type` レスポンスヘッダーを送信します。`422` は、プロバイダーを呼び出す前に Router が入力を拒否したことを意味し、`413` はリクエスト本文が Router の受け入れ可能なサイズを超えていたことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

上記のフィールド説明に記載されているサイズ制限は、プロバイダーの仕様から引用した、そのフィールドに対するプロバイダー自身の上限です。Router はリクエスト本文全体に対して別の上限を適用し、base64 エンコードされたメディアもこれにカウントされます。[リクエスト本文のサイズ](/ja/development/comfy-router/limitations) を参照してください。

このページは、Comfy Router 経由で呼び出す 1 つのパートナーモデルについて説明しています。同じ `comfy-sdk` / `@comfyorg/sdk` パッケージには、Comfy Cloud 上で ComfyUI のワークフローグラフ全体を実行するための 2 つ目のクライアントも含まれています: `Comfy(api_key=...)` / `new Comfy({ apiKey })`、および `client.workflows`、`client.assets`、`client.jobs`。[Comfy SDKs](/ja/development/api-development/sdks) を参照してください。

<CardGroup cols={3}>
  <Card title="ヘッダー" icon="list" href="/ja/development/comfy-router/headers">
    認証、冪等性、リクエスト ID、エラー分類、リトライ間隔、支出上限。
  </Card>

  <Card title="Router API の利用" icon="code" href="/ja/development/comfy-router/api">
    モデルの検出、バリデーションエラー、リトライ、課金。
  </Card>

  <Card title="制限事項" icon="triangle-exclamation" href="/ja/development/comfy-router/limitations">
    Router が現在対応していないことと、代替手段。
  </Card>
</CardGroup>


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