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

# Comfy Router で Veo 3.1 Generate 001 を使う

> Comfy Router 経由で veo/veo-3.1-generate-001 を呼び出します: エンドポイント、リクエストの形状、Router が返すレスポンス。

`veo/veo-3.1-generate-001` の API リファレンス。Veo から Comfy Router によって提供されます。

## クイックスタート

[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 スニペットは同じ呼び出しを生の HTTP で行うものです。

**モデル ID:** `veo/veo-3.1-generate-001`

**エンドポイント:** `POST https://api.comfy.org/v2/models/veo/veo-3.1-generate-001`

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

      # 環境変数から COMFY_API_KEY を読み取ります。
      # SDK は冪等性キーを自動的に作成し、自動リトライで再利用します。
      with Comfy() as client:
          result = client.models.run(
              "veo/veo-3.1-generate-001",
              {
                  "instances": [
                      {
                          "prompt": "a single red maple leaf falling onto still water, slow motion",
                      },
                  ],
                  "parameters": {
                      "durationSeconds": 4,
                      "generateAudio": False,
                      "sampleCount": 1,
                  },
              },
          )

      print(result)
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // SDK は冪等性キーを自動的に作成し、自動リトライで再利用します。
      const { data } = await comfy.models.run("veo/veo-3.1-generate-001", {
        instances: [
          {
            prompt: "a single red maple leaf falling onto still water, slow motion",
          },
        ],
        parameters: {
          durationSeconds: 4,
          generateAudio: false,
          sampleCount: 1,
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/veo/veo-3.1-generate-001 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"instances\": [{\"prompt\":\"a single red maple leaf falling onto still water, slow motion\"}], \"parameters\": {\"durationSeconds\":4,\"generateAudio\":false,\"sampleCount\":1}}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="キューに送信して後で収集する">
    同じボディを `POST https://api.comfy.org/v2/models/veo/veo-3.1-generate-001/requests` に送信します。Router は実行が受理されるとすぐに `201` と `request_id` を返し、結果は準備ができ次第、このプロセスからでも別のプロセスからでも収集できます。[キュー配信](/ja/development/comfy-router/queue)では、ステータス、キャンセル、収集の流れを説明しています。

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

      # 環境変数から COMFY_API_KEY を読み取ります。
      # submit() を呼び出すたびに独自の Idempotency-Key を発行し、自動リトライでも再利用します。
      async def main():
          async with AsyncComfy() as client:
              handle = await client.models.submit(
                  "veo/veo-3.1-generate-001",
                  {
                      "instances": [
                          {
                              "prompt": "a single red maple leaf falling onto still water, slow motion",
                          },
                      ],
                      "parameters": {
                          "durationSeconds": 4,
                          "generateAudio": False,
                          "sampleCount": 1,
                      },
                  },
              )
              print("request_id:", handle.request_id)  # モデル ID と合わせれば、別のプロセスに必要なものはこれだけです

              # リクエストが完了するまでポーリングし、サーバーが指定する Retry-After だけ待機します。
              async for update in handle.iter_events():
                  print(update.status, update.queue_position)

              # プロバイダー自身のペイロードで、models.run() が返す値と同じものです。
              # 失敗またはキャンセルされたリクエストでは、ここで型付きの Router エラーが発生します。
              result = await handle.get()

          print(result)

      asyncio.run(main())
      ```

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

      // 環境変数から COMFY_API_KEY を読み取ります。
      // submit() を呼び出すたびに独自の Idempotency-Key を発行し、自動リトライでも再利用します。
      const handle = await comfy.models.submit("veo/veo-3.1-generate-001", {
        instances: [
          {
            prompt: "a single red maple leaf falling onto still water, slow motion",
          },
        ],
        parameters: {
          durationSeconds: 4,
          generateAudio: false,
          sampleCount: 1,
        },
      });
      console.log("requestId:", handle.requestId); // モデル ID と合わせれば、別のプロセスに必要なものはこれだけです

      // リクエストが完了するまでポーリングし、サーバーが指定する Retry-After だけ待機します。
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      // models.run() が返すのと同じ結果です。失敗またはキャンセルされたリクエストでは、ここで reject されます。
      const result = await handle.get();

      console.log(result.data);
      ```

      ```bash cURL theme={null}
      # 1. 送信。Router は request_id、status_url、response_url、cancel_url とともに 201 を返します。
      curl https://api.comfy.org/v2/models/veo/veo-3.1-generate-001/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"instances\": [{\"prompt\":\"a single red maple leaf falling onto still water, slow motion\"}], \"parameters\": {\"durationSeconds\":4,\"generateAudio\":false,\"sampleCount\":1}}"

      # 2. ステータスが COMPLETED になるまでポーリングし、各レスポンスが指定する Retry-After 秒だけ待機します。
      REQUEST_ID="<request_id from the 201 body>"
      curl -i https://api.comfy.org/v2/models/veo/veo-3.1-generate-001/requests/$REQUEST_ID/status \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 収集。モデルのネイティブ出力とともに 200、まだ実行中の場合はステータスボディとともに 202 を返します。
      curl https://api.comfy.org/v2/models/veo/veo-3.1-generate-001/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="instances" type="object[]" />

<ParamField body="instances[].cameraControl" type="string">
  カメラのモーションタイプ。画像の指定が必要です。

  指定可能な値: `fixed`、`pan_left`、`pan_right`、`tilt_up`、`tilt_down`、`truck_left`、`truck_right`、`pedestal_up`、`pedestal_down`、`push_in`、`pull_out`
</ParamField>

<ParamField body="instances[].image" type="object">
  ビデオ生成をガイドするためのオプションの先頭フレーム画像
</ParamField>

<ParamField body="instances[].image.bytesBase64Encoded" type="string (byte)">
  Base64 でエンコードされた画像データ

  形式: `byte`
</ParamField>

<ParamField body="instances[].image.gcsUri" type="string">
  画像の Cloud Storage URI
</ParamField>

<ParamField body="instances[].image.mimeType" type="string">
  画像の MIME タイプ (image/jpeg または image/png)

  指定可能な値: `image/jpeg`、`image/png`
</ParamField>

<ParamField body="instances[].lastFrame" type="object">
  オプションの末尾フレーム画像。image と併用して先頭フレームと末尾フレームの間のビデオを生成します。Veo 3.0 以降のモデルでサポートされています。
</ParamField>

<ParamField body="instances[].lastFrame.bytesBase64Encoded" type="string (byte)">
  Base64 でエンコードされた画像データ

  形式: `byte`
</ParamField>

<ParamField body="instances[].lastFrame.gcsUri" type="string">
  画像の Cloud Storage URI
</ParamField>

<ParamField body="instances[].lastFrame.mimeType" type="string">
  画像の MIME タイプ (image/jpeg または image/png)

  指定可能な値: `image/jpeg`、`image/png`
</ParamField>

<ParamField body="instances[].mask" type="object">
  ビデオ編集用のオプションのマスク。入力ビデオに適用されます。
</ParamField>

<ParamField body="instances[].mask.bytesBase64Encoded" type="string (byte)">
  Base64 でエンコードされたマスクのバイト列

  形式: `byte`
</ParamField>

<ParamField body="instances[].mask.gcsUri" type="string">
  マスクファイルの Cloud Storage URI
</ParamField>

<ParamField body="instances[].mask.maskMode" type="string">
  マスクの適用方法

  指定可能な値: `insert`、`remove`、`remove_static`、`outpaint`
</ParamField>

<ParamField body="instances[].mask.mimeType" type="string">
  マスクの MIME タイプ (image/png、image/jpeg、image/webp、またはビデオ形式)
</ParamField>

<ParamField body="instances[].prompt" type="string" required>
  生成するビデオのテキストによる説明
</ParamField>

<ParamField body="instances[].referenceImages" type="object[]">
  ビデオ生成をガイドするためのオプションの参照画像。最大 3 枚のアセット画像または 1 枚のスタイル画像をサポートします。Veo 3.1 モデル (プレビュー) でサポートされています。
</ParamField>

<ParamField body="instances[].referenceImages[].image" type="object" required />

<ParamField body="instances[].referenceImages[].image.bytesBase64Encoded" type="string (byte)">
  Base64 でエンコードされた画像データ

  形式: `byte`
</ParamField>

<ParamField body="instances[].referenceImages[].image.gcsUri" type="string">
  画像の Cloud Storage URI
</ParamField>

<ParamField body="instances[].referenceImages[].image.mimeType" type="string">
  画像の MIME タイプ (image/jpeg または image/png)

  指定可能な値: `image/jpeg`、`image/png`
</ParamField>

<ParamField body="instances[].referenceImages[].referenceId" type="string">
  参照画像の任意の識別子
</ParamField>

<ParamField body="instances[].referenceImages[].referenceType" type="string" required>
  参照画像のタイプ

  指定可能な値: `asset`、`style`
</ParamField>

<ParamField body="instances[].video" type="object">
  ビデオの拡張または編集用のオプションの入力ビデオ。image および referenceImages とは併用できません。
</ParamField>

<ParamField body="instances[].video.bytesBase64Encoded" type="string (byte)">
  Base64 でエンコードされたビデオのバイト列

  形式: `byte`
</ParamField>

<ParamField body="instances[].video.gcsUri" type="string">
  入力ビデオの Cloud Storage URI
</ParamField>

<ParamField body="instances[].video.mimeType" type="string">
  ビデオの MIME タイプ

  指定可能な値: `video/mov`、`video/mpeg`、`video/mp4`、`video/mpg`、`video/avi`、`video/wmv`、`video/mpegps`、`video/x-flv`
</ParamField>

<ParamField body="parameters" type="object" />

<ParamField body="parameters.aspectRatio" type="string">
  生成されるビデオのアスペクト比。デフォルト: 16:9

  指定可能な値: `16:9`、`9:16`
</ParamField>

<ParamField body="parameters.compressionQuality" type="string">
  ビデオの圧縮品質。デフォルト: optimized

  指定可能な値: `optimized`、`lossless`
</ParamField>

<ParamField body="parameters.durationSeconds" type="number">
  生成されるビデオの目標再生時間 (秒)。Veo 2: 5～8。Veo 3/3.1: 4、6、または 8。デフォルト: 8
</ParamField>

<ParamField body="parameters.enhancePrompt" type="boolean">
  高品質化のためにプロンプトを自動的に改善します。デフォルトは true です。
</ParamField>

<ParamField body="parameters.fps" type="integer">
  生成されるビデオのフレームレート (1 秒あたりのフレーム数)
</ParamField>

<ParamField body="parameters.generateAudio" type="boolean">
  ビデオとともにオーディオを生成するかどうか。デフォルトは true です。Veo 3.0 以降のモデルでサポートされています。
</ParamField>

<ParamField body="parameters.negativePrompt" type="string">
  生成されるビデオで避けるべき内容を記述したテキスト
</ParamField>

<ParamField body="parameters.personGeneration" type="string">
  生成されるビデオ内の人物を制御します。デフォルト: allow\_adult

  指定可能な値: `dont_allow`、`allow_adult`、`allowAll`
</ParamField>

<ParamField body="parameters.pubsubTopic" type="string">
  進捗更新用の Cloud Pub/Sub トピック (projects/\{project}/topics/\{topic})
</ParamField>

<ParamField body="parameters.resizeMode" type="string">
  入力画像のリサイズ方法。デフォルト: pad

  指定可能な値: `pad`、`crop`
</ParamField>

<ParamField body="parameters.resolution" type="string">
  出力ビデオの解像度。Veo 3.0 以降のモデルでサポートされています。デフォルト: 720p

  指定可能な値: `720p`、`1080p`、`4k`
</ParamField>

<ParamField body="parameters.sampleCount" type="integer">
  生成するビデオの本数。指定しない場合は 1 本のビデオが生成されます。

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

<ParamField body="parameters.seed" type="integer">
  決定論的な出力のためのランダムシード。sampleCount > 1 の場合、ビデオごとに異なるシードが使用されます。

  形式: `uint32`
</ParamField>

<ParamField body="parameters.storageUri" type="string">
  生成されたビデオを保存するための Cloud Storage URI (gs\://)
</ParamField>

<ParamField body="parameters.task" type="string">
  ビデオ生成リクエストの操作タイプ

  指定可能な値: `textToVideo`, `imageToVideo`, `referenceToVideo`, `edit`, `extend`, `upscale`
</ParamField>

Router が `GET /v2/models/veo/veo-3.1-generate-001/openapi.json` で提供するスキーマから生成されたもので、リクエストがプロバイダーに到達する前に Router が呼び出しを検証する際に使用するドキュメントと同じです。

### 出力

<ResponseField name="done" type="boolean">
  オペレーションが完了したかどうか
</ResponseField>

<ResponseField name="error" type="object">
  エラーの詳細。オペレーションが失敗した場合に含まれます
</ResponseField>

<ResponseField name="error.code" type="integer">
  gRPC エラーコード
</ResponseField>

<ResponseField name="error.message" type="string">
  エラーメッセージ
</ResponseField>

<ResponseField name="name" type="string">
  オペレーションのリソース名
</ResponseField>

<ResponseField name="response" type="object">
  予測レスポンス。done が true の場合に含まれます
</ResponseField>

<ResponseField name="response.@type" type="string" />

<ResponseField name="response.raiMediaFilteredCount" type="integer">
  責任ある AI ポリシーによってフィルタリングされたビデオの数
</ResponseField>

<ResponseField name="response.raiMediaFilteredReasons" type="string[]">
  責任ある AI ポリシーによってビデオがフィルタリングされた理由
</ResponseField>

<ResponseField name="response.videos" type="object[]" />

<ResponseField name="response.videos[].bytesBase64Encoded" type="string">
  Base64 エンコードされたビデオコンテンツ
</ResponseField>

<ResponseField name="response.videos[].gcsUri" type="string">
  生成されたビデオの Cloud Storage URI
</ResponseField>

<ResponseField name="response.videos[].mimeType" type="string">
  ビデオの MIME タイプ (video/mp4)
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "instances": [
    {
      "prompt": "a single red maple leaf falling onto still water, slow motion"
    }
  ],
  "parameters": {
    "durationSeconds": 4,
    "generateAudio": false,
    "sampleCount": 1
  }
}
```

### 出力

```json theme={null}
{
  "done": true,
  "name": "projects/example-project/locations/us-central1/publishers/google/models/veo-3.1-fast-generate-001/operations/1a2b3c4d",
  "response": {
    "@type": "type.googleapis.com/cloud.ai.large_models.vision.GenerateVideoResponse",
    "raiMediaFilteredCount": 0,
    "videos": [
      {
        "gcsUri": "https://storage.googleapis.com/EXAMPLE_BUCKET/veo/USER_ID/REQUEST_ID/sample_0.mp4",
        "mimeType": "video/mp4"
      }
    ]
  }
}
```

## 出荷前の確認

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>
