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

# Comfy Router で FLUX 3 Video を使用する

> Comfy Router 経由の HTTP で FLUX 3 から音声が同期されたビデオを生成するための Python、TypeScript、cURL スニペット、およびリクエストフィールドと結果の形状

FLUX 3 Video の API リファレンス。FLUX 3 Video は Black Forest Labs のビデオ生成モデルで、テキストプロンプトから同期したオーディオ付きの短いクリップを生成します。

## クイックスタート

[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:** `bfl/flux-3-video`

**エンドポイント:** `POST https://api.comfy.org/v2/models/bfl/flux-3-video`

<Tabs>
  <Tab title="Wait for the result">
    <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(
              "bfl/flux-3-video",
              {
                  "mode": "t2v",
                  "prompt": "a single red maple leaf falling onto still water, slow motion",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "generate_audio": True,
              },
          )

      print("video:", result["result"]["sample"])
      ```

      ```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 = { result: { sample: string } };
      const { data } = await comfy.models.run<Result>("bfl/flux-3-video", {
        mode: "t2v",
        prompt: "a single red maple leaf falling onto still water, slow motion",
        duration: 5,
        aspect_ratio: "16:9",
        generate_audio: true,
      });

      console.log("video:", data.result.sample);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/bfl/flux-3-video \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"mode\": \"t2v\", \"prompt\": \"a single red maple leaf falling onto still water, slow motion\", \"duration\": 5, \"aspect_ratio\": \"16:9\", \"generate_audio\": true}"
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Queue and collect later">
    <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(
              "bfl/flux-3-video",
              {
                  "mode": "t2v",
                  "prompt": "a single red maple leaf falling onto still water, slow motion",
                  "duration": 5,
                  "aspect_ratio": "16:9",
                  "generate_audio": True,
              },
          )
          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("video:", result["result"]["sample"])
      ```

      ```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 = { result: { sample: string } };
      const handle = await comfy.models.submit<Result>("bfl/flux-3-video", {
        mode: "t2v",
        prompt: "a single red maple leaf falling onto still water, slow motion",
        duration: 5,
        aspect_ratio: "16:9",
        generate_audio: true,
      });
      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("video:", result.data.result.sample);
      ```

      ```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/bfl/flux-3-video/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"mode\": \"t2v\", \"prompt\": \"a single red maple leaf falling onto still water, slow motion\", \"duration\": 5, \"aspect_ratio\": \"16:9\", \"generate_audio\": true}"

      # 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/bfl/flux-3-video/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/bfl/flux-3-video/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## スキーマ

### 入力

<ParamField body="aspect_ratio" type="string" default="&#x22;auto&#x22;">
  出力アスペクト比: auto、21:9、2:1、16:9、4:3、1:1、3:4、または 9:16。auto を指定すると、BFL がプロンプトと参照素材から選択します。
</ParamField>

<ParamField body="draft" type="boolean" default="false">
  ドラフトモード: 高速なプレビューを生成します。その結果には draft\_cache のダウンロード URL が含まれます。そのバンドルを mode draft\_enhance とともに送り返すと、同じ生成のフル品質版がレンダリングされます。
</ParamField>

<ParamField body="draft_cache" type="string">
  draft\_enhance 専用。以前のドラフト生成で得られた暗号化されたドラフトキャッシュバンドルを、base64 エンコードされたダウンロード済みバンドル、またはまだ有効な http(s) URL として指定します。元の入力はバンドルに埋め込まれています。
</ParamField>

<ParamField body="duration" type="integer | string" default="&#x22;auto&#x22;">
  ビデオの再生時間（秒、5 から 20 までの任意の整数秒）、またはコンテンツに合わせる場合は auto。

  範囲: `5` から `20`
</ParamField>

<ParamField body="generate_audio" type="boolean" default="true">
  ビデオと同時に同期オーディオを生成します。
</ParamField>

<ParamField body="keyframes" type="string | number | string[] | string[] | number | string[][]">
  i2v 専用。ビデオのフレームとなる画像で、それぞれ http(s) URL または base64、合計 1 枚から 10 枚です。単一の画像、画像のリスト（1 枚ならビデオの開始、2 枚なら開始と終了、それ以上は均等に配置され、再生時間の指定が必要）、またはタイムスタンプ付きの \[秒, 画像] ペアを時系列順に指定できます。例: \[\[0, "..."], \[3.5, "..."] ]。ペアは 2 要素の配列で、最初が秒数、次が画像です。
</ParamField>

<ParamField body="mode" type="string" required>
  生成モード: t2v（テキストから動画へ）、i2v（画像からの継続）、v2v（ビデオからの継続）、または draft\_enhance（以前のドラフトのフル品質レンダリング）。text-to-video のような省略しない別名も受け付けます。
</ParamField>

<ParamField body="prompt" type="string">
  ビデオを記述する自由形式のプロンプト。draft\_enhance を除くすべてのモードで必須です。
</ParamField>

<ParamField body="resolution" type="string">
  ビデオの解像度クラス: hd、またはビデオアップサンプラーで仕上げられた高解像度の結果を得る fhd。デフォルトは t2v、i2v、v2v では hd、draft\_enhance では fhd です。正確な寸法はアスペクト比によって異なります。

  指定可能な値: `hd`, `fhd`
</ParamField>

<ParamField body="safety_tolerance" type="integer" default="2">
  入力および出力の有害性モデレーションの許容値で、0 が最も厳格です。性的コンテンツは要求された許容値にかかわらずレベル 3 に、ヘイトコンテンツはレベル 2 に制限されます。条件付けメディアを含むリクエストはレベル 2 に制限されます。

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

<ParamField body="start_video" type="string">
  v2v 専用。継続するビデオで、http(s) URL または base64 MP4 です。生成されるクリップはその最終フレームから続きます。
</ParamField>

<ParamField body="version" type="string" default="&#x22;latest&#x22;">
  エンドポイントのバージョン。latest は現在のリリースを提供し、日付付きの固定可能なリリースタグは公開され次第追加されます。
</ParamField>

この内容は、Router が `GET /v2/models/bfl/flux-3-video/openapi.json` で提供するスキーマから生成されたもので、リクエストがプロバイダーに到達する前に Router が呼び出しを検証する対象となるドキュメントと同じものです。

### 出力

<ResponseField name="cost" type="number">
  プロバイダーが報告するクレジット単位のコスト。タスクが Ready になると設定されます。

  形式: `float`
</ResponseField>

<ResponseField name="id" type="string" required>
  BFL のタスク識別子。
</ResponseField>

<ResponseField name="progress" type="number">
  BFL が報告する任意の生成進捗。

  範囲: `0` から `1`

  形式: `float`
</ResponseField>

<ResponseField name="result" type="object" required>
  完了した生成。2 つの URL リーフのうち、どちらか一方だけが設定されます。デフォルトモードでは `sample`、`draft: true` モードでは `draft_cache` です。
</ResponseField>

<ResponseField name="result.cost" type="number">
  プロバイダーが報告するタスクコスト。これは BFL の数値であり、Comfy の課金ではありません。

  形式: `double`
</ResponseField>

<ResponseField name="result.draft_cache" type="string (uri)">
  `draft: true` モードで `sample` の代わりに返される署名付き URL。`sample` と同じ方法で Comfy ストレージに再ホストされます。通常は最大 24 時間有効な Comfy ホストの URL で、再ホストを実行できなかった場合は BFL 自身のおおよそ 2 時間有効な配信 URL になります。

  形式: `uri`
</ResponseField>

<ResponseField name="result.sample" type="string (uri)">
  生成された MP4 の署名付き URL。Router はアセットを Comfy ストレージに再ホストしてこのフィールドを書き換えるため、通常は最大 24 時間有効な Comfy ホストの URL になります。発行時に 24 時間で署名され、23 時間のメモから再生されるため、後でのポーリングでは残り 1 時間しかない URL が返されることがあります。再ホストを実行できなかったリーフは、代わりに BFL 自身のおおよそ 2 時間有効な配信 URL を保持します。`draft: true` モードでは存在しません。

  形式: `uri`
</ResponseField>

<ResponseField name="status" type="string" required>
  タスクのステータス: Pending、Reasoning、Generating、Ready、Request Moderated、Content Moderated、Error、または Task not found。大文字と小文字を区別せずに比較してください。Router は BFL の表記をそのまま転送します。
</ResponseField>

## 例

### 入力

```json theme={null}
{
  "mode": "t2v",
  "prompt": "a single red maple leaf falling onto still water, slow motion",
  "duration": 5,
  "aspect_ratio": "16:9",
  "generate_audio": true
}
```

### 出力

```json theme={null}
{
  "id": "0a1b2c3d-...",
  "status": "Ready",
  "result": {
    "sample": "https://.../out.mp4"
  }
}
```

`result.sample` は通常、Comfy がホストする署名付き URL で、作成から最大 24 時間有効です。リプレイでは古い URL が返されることがあり、再ホストできなかったアセットは有効期間の短いプロバイダー URL のままになります。リンクを保存せず、MP4 を速やかにダウンロードしてください。`draft: true` の場合は、`result.sample` を期待するのではなく `result.draft_cache` を参照してください。

## 出荷前の確認

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>
