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

# Use FLUX 3 Video with Comfy Router

> Python, TypeScript and cURL snippets for generating video with synchronized audio from FLUX 3 over HTTP through Comfy Router, plus the request fields and the result shape

API Reference for FLUX 3 Video. FLUX 3 Video is Black Forest Labs' video generation model, turning a text prompt into a short clip with synchronized audio.

## Quick start

Create a key in [your Comfy workspace](https://platform.comfy.org/profile/api-keys) and export it as `COMFY_API_KEY`. The Python and TypeScript snippets use the Comfy SDKs (`pip install comfy-sdk`, `npm install @comfyorg/sdk`); the cURL snippet is the same call over raw HTTP.

**Model ID:** `bfl/flux-3-video`

**Endpoint:** `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">
    <Note>
      Queued delivery is rolling out per workspace. Until yours is enabled, the submit route answers `403` with `X-Comfy-Error-Type: not_enabled`. Nothing about the request is wrong, and the same body works through the synchronous route in the meantime.
    </Note>

    The same body, sent to `POST https://api.comfy.org/v2/models/bfl/flux-3-video/requests`. Router answers `201` with a `request_id` as soon as the run is admitted, and the result is collected once it is ready, from this process or another one. [Queued delivery](/development/comfy-router/queue) walks through status, cancellation and collection.

    <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>

## Schema

### Input

<ParamField body="aspect_ratio" type="string" default="&#x22;auto&#x22;">
  Output aspect ratio: auto, 21:9, 2:1, 16:9, 4:3, 1:1, 3:4, or 9:16. auto lets BFL choose from the prompt and any references.
</ParamField>

<ParamField body="draft" type="boolean" default="false">
  Draft mode: generate a fast preview whose result includes a draft\_cache download URL. Send that bundle back with mode draft\_enhance to render the full-quality version of the same generation.
</ParamField>

<ParamField body="draft_cache" type="string">
  draft\_enhance only. Encrypted draft-cache bundle from a prior draft generation, as the base64-encoded downloaded bundle or its still-valid http(s) URL. The original inputs are embedded in the bundle.
</ParamField>

<ParamField body="duration" type="integer | string" default="&#x22;auto&#x22;">
  Video duration in seconds (any whole second from 5 to 20), or auto to fit the content.

  Range: `5` to `20`
</ParamField>

<ParamField body="generate_audio" type="boolean" default="true">
  Generate synchronized audio alongside the video.
</ParamField>

<ParamField body="keyframes" type="string | number | string[] | string[] | number | string[][]">
  i2v only. Images that become frames of the video, each an http(s) URL or base64, one to ten total. Accepts a single image, a list of images (one starts the video, two start and end it, more spread evenly and need a set duration), or timestamped \[seconds, image] pairs in time order, e.g. \[\[0, "..."], \[3.5, "..."]]. A pair is a two-element array: number of seconds first, then the image.
</ParamField>

<ParamField body="mode" type="string" required>
  Generation mode: t2v (text-to-video), i2v (image-continuation), v2v (video-continuation), or draft\_enhance (full-quality render of a prior draft). Spelled-out aliases such as text-to-video are accepted.
</ParamField>

<ParamField body="prompt" type="string">
  Free-form prompt describing the video. Required for every mode except draft\_enhance.
</ParamField>

<ParamField body="resolution" type="string">
  Video resolution class: hd, or fhd for a higher-resolution result finished by the video upsampler. Defaults to hd for t2v, i2v and v2v, and to fhd for draft\_enhance. Exact dimensions vary with the aspect ratio.

  Possible values: `hd`, `fhd`
</ParamField>

<ParamField body="safety_tolerance" type="integer" default="2">
  Tolerance level for input and output harm moderation, 0 strictest. Sexual content is limited to level 3 and hate content to level 2 regardless of the requested tolerance; requests with conditioning media are limited to level 2.

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

<ParamField body="start_video" type="string">
  v2v only. The video to continue, an http(s) URL or base64 MP4; the generated clip carries on from its final frames.
</ParamField>

<ParamField body="version" type="string" default="&#x22;latest&#x22;">
  Endpoint version. latest serves the current release; dated pinnable release tags are added as they are published.
</ParamField>

Generated from the schema Router serves at `GET /v2/models/bfl/flux-3-video/openapi.json`, the same document it validates a call against before the request reaches the provider.

### Output

<ResponseField name="cost" type="number">
  Provider-reported cost in credits, populated once the task is Ready.

  Format: `float`
</ResponseField>

<ResponseField name="id" type="string" required>
  BFL task identifier.
</ResponseField>

<ResponseField name="progress" type="number">
  Optional generation progress reported by BFL.

  Range: `0` to `1`

  Format: `float`
</ResponseField>

<ResponseField name="result" type="object" required>
  The finished generation. Exactly one of the two URL leaves is populated: `sample` in the default mode, `draft_cache` in `draft: true` mode.
</ResponseField>

<ResponseField name="result.cost" type="number">
  Provider-reported task cost. This is BFL's number, not the Comfy charge.

  Format: `double`
</ResponseField>

<ResponseField name="result.draft_cache" type="string (uri)">
  Signed URL returned INSTEAD of `sample` by the `draft: true` mode, re-hosted onto Comfy storage the same way `sample` is: normally a Comfy-hosted URL valid for up to 24 hours, and BFL's own roughly two-hour delivery URL when the re-host could not be performed.

  Format: `uri`
</ResponseField>

<ResponseField name="result.sample" type="string (uri)">
  Signed URL for the generated MP4. Router re-hosts the asset onto Comfy storage and rewrites this field, so it is normally a Comfy-hosted URL valid for up to 24 hours - signed for 24 hours when minted and replayed from a 23-hour memo, so a later poll can hand back one with as little as an hour left; a leaf whose re-host could not be performed keeps BFL's own roughly two-hour delivery URL instead. Absent in `draft: true` mode.

  Format: `uri`
</ResponseField>

<ResponseField name="status" type="string" required>
  Task status: Pending, Reasoning, Generating, Ready, Request Moderated, Content Moderated, Error, or Task not found. Compare case-insensitively; Router forwards BFL's spelling unchanged.
</ResponseField>

## Examples

### Input

```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
}
```

### Output

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

`result.sample` is normally a Comfy-hosted signed URL, valid for up to 24 hours from creation. A replay can return an older URL, and an asset that could not be re-hosted keeps its shorter-lived provider URL. Download the MP4 promptly rather than storing the link. With `draft: true`, read `result.draft_cache` instead of expecting `result.sample`.

## Before you ship

The SDKs create an `Idempotency-Key` and reuse it for automatic retries. For manual retries, reuse the original key. Router can hold the connection for up to 10 minutes.

When a request fails, Router sends an `X-Comfy-Error-Type` response header explaining why. A `422` means Router rejected the input before calling the provider. Download generated assets promptly because [result URLs can expire](/development/comfy-router/reference#result-assets).

<CardGroup cols={3}>
  <Card title="Headers" icon="list" href="/development/comfy-router/headers">
    Authentication, idempotency, request IDs, error buckets, retry pacing, spend limits.
  </Card>

  <Card title="Using the Router API" icon="code" href="/development/comfy-router/api">
    Model discovery, validation errors, retries, and billing.
  </Card>

  <Card title="Limitations" icon="triangle-exclamation" href="/development/comfy-router/limitations">
    What Router does not do today, and what to use instead.
  </Card>
</CardGroup>
