> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-chore-sync-comfy-api-v2-spec.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router で Veo 2.0 Generate 001 を使用する

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

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

## クイックスタート

[Comfy ワークスペース](https://platform.comfy.org/profile/api-keys)でキーを作成し、`COMFY_API_KEY` としてエクスポートします。Python と TypeScript のスニペットは Comfy SDK（`pip install comfy-sdk`、`npm install @comfyorg/sdk`）を使用しています。cURL スニペットは同じ呼び出しを生の HTTP で実行するものです。

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

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

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

      # Reads COMFY_API_KEY from the environment.
      # The SDK automatically creates an idempotency key and reuses it for automatic retries.
      with Comfy() as client:
          result = client.models.run(
              "veo/veo-2.0-generate-001",
              {
                  "instances": [
                      {
                          "prompt": "a single red maple leaf falling onto still water, slow motion",
                      },
                  ],
                  "parameters": {
                      "durationSeconds": 6,
                      "sampleCount": 1,
                  },
              },
          )

      print(result)
      ```

      ```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.
      const { data } = await comfy.models.run("veo/veo-2.0-generate-001", {
        instances: [
          {
            prompt: "a single red maple leaf falling onto still water, slow motion",
          },
        ],
        parameters: {
          durationSeconds: 6,
          sampleCount: 1,
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/veo/veo-2.0-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\":6,\"sampleCount\":1}}"
      ```
    </CodeGroup>
  </Tab>

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

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

      # Reads COMFY_API_KEY from the environment.
      # Each submit() call mints its own Idempotency-Key and reuses it for automatic retries.
      with Comfy() as client:
          handle = client.models.submit(
              "veo/veo-2.0-generate-001",
              {
                  "instances": [
                      {
                          "prompt": "a single red maple leaf falling onto still water, slow motion",
                      },
                  ],
                  "parameters": {
                      "durationSeconds": 6,
                      "sampleCount": 1,
                  },
              },
          )
          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.
          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 = handle.get()

      print(result)
      ```

      ```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.
      const handle = await comfy.models.submit("veo/veo-2.0-generate-001", {
        instances: [
          {
            prompt: "a single red maple leaf falling onto still water, slow motion",
          },
        ],
        parameters: {
          durationSeconds: 6,
          sampleCount: 1,
        },
      });
      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();

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

      ```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/veo/veo-2.0-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\":6,\"sampleCount\":1}}"

      # 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/veo/veo-2.0-generate-001/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/veo/veo-2.0-generate-001/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

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

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

<ParamField body="instances[].image.bytesBase64Encoded" type="string (byte)">
  形式: `byte`
</ParamField>

<ParamField body="instances[].image.gcsUri" type="string" />

<ParamField body="instances[].image.mimeType" type="string" />

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

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

<ParamField body="parameters.aspectRatio" type="string" />

<ParamField body="parameters.durationSeconds" type="integer" />

<ParamField body="parameters.enhancePrompt" type="boolean" />

<ParamField body="parameters.negativePrompt" type="string" />

<ParamField body="parameters.personGeneration" type="string">
  生成されるビデオに人物を含めるかを制御します。`dont_allow`、`allow_adult`、`allowAll` は Vertex AI 独自の表記であり、同じフィールドに対して VeoGenVidRequest が公開している値です。`ALLOW` と `BLOCK` は、このコンポーネントが Router 製になる前にこのコンポーネントから生成されたクライアントとの互換性のために保持されています。詳細は Veo2GenVidRequest の冒頭の注記を参照してください。

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

<ParamField body="parameters.sampleCount" type="integer" />

<ParamField body="parameters.seed" type="integer">
  形式: `uint32`
</ParamField>

<ParamField body="parameters.storageUri" type="string">
  ビデオをアップロードするためのオプションの Cloud Storage URI
</ParamField>

Router が `GET /v2/models/veo/veo-2.0-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": 6,
    "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 が入力を拒否したことを意味します。生成されたアセットは [結果 URL の有効期限](/ja/development/comfy-router/reference#結果アセット) があるため、早めにダウンロードしてください。

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

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

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