> ## 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 Ray Flash 2 with Comfy Router

> Call luma/ray-flash-2 through Comfy Router: endpoint, request shape and the response Router returns.

API Reference for `luma/ray-flash-2`, served by Comfy Router from Luma.

## 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:** `luma/ray-flash-2`

**Endpoint:** `POST https://api.comfy.org/v2/models/luma/ray-flash-2`

<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(
              "luma/ray-flash-2",
              {
                  "aspect_ratio": "16:9",
                  "duration": "5s",
                  "prompt": "a single red maple leaf resting on a plain white background",
                  "resolution": "540p",
              },
          )

      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("luma/ray-flash-2", {
        aspect_ratio: "16:9",
        duration: "5s",
        prompt: "a single red maple leaf resting on a plain white background",
        resolution: "540p",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/luma/ray-flash-2 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"16:9\", \"duration\": \"5s\", \"prompt\": \"a single red maple leaf resting on a plain white background\", \"resolution\": \"540p\"}"
      ```
    </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/luma/ray-flash-2/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(
              "luma/ray-flash-2",
              {
                  "aspect_ratio": "16:9",
                  "duration": "5s",
                  "prompt": "a single red maple leaf resting on a plain white background",
                  "resolution": "540p",
              },
          )
          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("luma/ray-flash-2", {
        aspect_ratio: "16:9",
        duration: "5s",
        prompt: "a single red maple leaf resting on a plain white background",
        resolution: "540p",
      });
      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/luma/ray-flash-2/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"aspect_ratio\": \"16:9\", \"duration\": \"5s\", \"prompt\": \"a single red maple leaf resting on a plain white background\", \"resolution\": \"540p\"}"

      # 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/luma/ray-flash-2/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/luma/ray-flash-2/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### Input

<ParamField body="aspect_ratio" type="string" required default="&#x22;16:9&#x22;">
  The aspect ratio of the generation

  Possible values: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `21:9`, `9:21`
</ParamField>

<ParamField body="callback_url" type="string (uri)">
  The callback URL of the generation, a POST request with Generation object will be sent to the callback URL when the generation is dreaming, completed, or failed

  Format: `uri`
</ParamField>

<ParamField body="duration" type="`5s`, `9s` | string" required />

<ParamField body="generation_type" type="string" default="&#x22;video&#x22;">
  Possible values: `video`
</ParamField>

<ParamField body="keyframes" type="object">
  The keyframes of the generation
</ParamField>

<ParamField body="keyframes.frame0" type="object">
  A keyframe can be either a Generation reference, an Image, or a Video
</ParamField>

<ParamField body="keyframes.frame1" type="object">
  A keyframe can be either a Generation reference, an Image, or a Video
</ParamField>

<ParamField body="loop" type="boolean">
  Whether to loop the video
</ParamField>

<ParamField body="model" type="string">
  The video model used for the generation. On the Comfy Router route `POST /v2/models/luma/{model}` this field is supplied from the path and MUST NOT be sent; on the v1 `POST /proxy/luma/generations` route it is required and constrained to the LumaVideoModel enum (`ray-2`, `ray-flash-2`).
</ParamField>

<ParamField body="prompt" type="string" required>
  The prompt of the generation
</ParamField>

<ParamField body="resolution" type="`540p`, `720p`, `1080p`, `4k` | string" required />

Generated from the schema Router serves at `GET /v2/models/luma/ray-flash-2/openapi.json`, the same document it validates a call against before the request reaches the provider.

### Output

<ResponseField name="assets" type="object">
  The assets of the generation
</ResponseField>

<ResponseField name="assets.image" type="string (uri)">
  The URL of the image

  Format: `uri`
</ResponseField>

<ResponseField name="assets.progress_video" type="string (uri)">
  The URL of the progress video

  Format: `uri`
</ResponseField>

<ResponseField name="assets.video" type="string (uri)">
  The URL of the video

  Format: `uri`
</ResponseField>

<ResponseField name="created_at" type="string (date-time)">
  The date and time when the generation was created

  Format: `date-time`
</ResponseField>

<ResponseField name="failure_reason" type="string">
  The reason for the state of the generation
</ResponseField>

<ResponseField name="generation_type" type="string">
  Possible values: `video`, `image`
</ResponseField>

<ResponseField name="id" type="string (uuid)">
  The ID of the generation

  Format: `uuid`
</ResponseField>

<ResponseField name="model" type="string">
  The model used for the generation
</ResponseField>

<ResponseField name="request" type="object">
  The request of the generation
</ResponseField>

<ResponseField name="state" type="string">
  The state of the generation

  Possible values: `queued`, `dreaming`, `completed`, `failed`
</ResponseField>

## Examples

### Input

```json theme={null}
{
  "aspect_ratio": "16:9",
  "duration": "5s",
  "prompt": "a single red maple leaf resting on a plain white background",
  "resolution": "540p"
}
```

### Output

```json theme={null}
{
  "assets": {
    "video": "https://example.invalid/luma/ray-flash-2/generated.mp4"
  },
  "created_at": "2027-01-01T00:00:00Z",
  "generation_type": "video",
  "id": "8c41d0b6-2e7a-4f35-b1d8-9a0e6f3c2b71",
  "model": "ray-flash-2",
  "state": "completed"
}
```

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