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

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

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

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