> ## 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 Uni 1 with Comfy Router

> Call luma_2/uni-1 through Comfy Router: endpoint, request shape and the response Router returns.

API Reference for `luma_2/uni-1`, served by Comfy Router from Luma 2.

## 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_2/uni-1`

**Endpoint:** `POST https://api.comfy.org/v2/models/luma_2/uni-1`

<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_2/uni-1",
              {
                  "prompt": "a red circle on a plain white background",
                  "type": "image",
              },
          )

      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_2/uni-1", {
        prompt: "a red circle on a plain white background",
        type: "image",
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/luma_2/uni-1 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"a red circle on a plain white background\", \"type\": \"image\"}"
      ```
    </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_2/uni-1/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_2/uni-1",
              {
                  "prompt": "a red circle on a plain white background",
                  "type": "image",
              },
          )
          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_2/uni-1", {
        prompt: "a red circle on a plain white background",
        type: "image",
      });
      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_2/uni-1/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"prompt\": \"a red circle on a plain white background\", \"type\": \"image\"}"

      # 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_2/uni-1/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_2/uni-1/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## Schema

### Input

<ParamField body="aspect_ratio" type="string">
  Output aspect ratio. The ray-3.2 video models support the subset 9:16, 3:4, 1:1, 4:3, 16:9, 21:9.

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

<ParamField body="image_ref" type="object[]">
  Reference images for style/content guidance. Up to 9 for type 'image', up to 8 for type 'image\_edit'.
</ParamField>

<ParamField body="image_ref[].data" type="string">
  Base64-encoded image or video data
</ParamField>

<ParamField body="image_ref[].generation_id" type="string">
  UUID of a prior completed generation to reuse as the source. Used by ray-3.2 video\_edit / video\_reframe.
</ParamField>

<ParamField body="image_ref[].media_type" type="string">
  MIME type. Required with data (and with url for video sources, e.g. video/mp4 on video\_edit / video\_reframe).
</ParamField>

<ParamField body="image_ref[].url" type="string">
  Publicly accessible image or video URL
</ParamField>

<ParamField body="model" type="string">
  Model to use. uni-1 / uni-1-max for image generation, ray-3.2 for video generation, editing, and reframing.
</ParamField>

<ParamField body="output_format" type="string">
  Output image format

  Possible values: `png`, `jpeg`
</ParamField>

<ParamField body="prompt" type="string" required>
  Text prompt
</ParamField>

<ParamField body="source" type="object">
  Reference to an image or video. Used for style/content guidance, guided generation, video-edit/video-reframe sources, and guide keyframes. Provide exactly one of generation\_id, url, or data.
</ParamField>

<ParamField body="source.data" type="string">
  Base64-encoded image or video data
</ParamField>

<ParamField body="source.generation_id" type="string">
  UUID of a prior completed generation to reuse as the source. Used by ray-3.2 video\_edit / video\_reframe.
</ParamField>

<ParamField body="source.media_type" type="string">
  MIME type. Required with data (and with url for video sources, e.g. video/mp4 on video\_edit / video\_reframe).
</ParamField>

<ParamField body="source.url" type="string">
  Publicly accessible image or video URL
</ParamField>

<ParamField body="style" type="string">
  Style preset

  Possible values: `auto`, `manga`
</ParamField>

<ParamField body="type" type="string">
  The kind of generation to perform. image/image\_edit are produced by the uni-1 / uni-1-max models; video/video\_edit/video\_reframe are produced by the ray-3.2 model.

  Possible values: `image`, `image_edit`, `video`, `video_edit`, `video_reframe`
</ParamField>

<ParamField body="video" type="object">
  Video output settings for ray-3.2. Only the fields that affect validation and billing are modelled here; additional fields (edit controls, end\_frame, loop, source\_position) are forwarded to Luma untouched.
</ParamField>

<ParamField body="video.duration" type="string">
  Clip duration for ray-3.2 video / video\_edit. Defaults to 5s. HDR generation (type video) is restricted to 5s.

  Possible values: `5s`, `10s`
</ParamField>

<ParamField body="video.exr_export" type="boolean">
  Export an EXR file alongside the MP4. Requires hdr true. Rejected for video\_reframe.
</ParamField>

<ParamField body="video.hdr" type="boolean">
  Render in HDR. Requires 720p/1080p. Rejected for video\_reframe.
</ParamField>

<ParamField body="video.keyframes" type="object[]">
  Guide-frame images. A single keyframe makes a type "video" request a single-keyframe extend, which always bills as one 5s block.
</ParamField>

<ParamField body="video.keyframes[].data" type="string">
  Base64-encoded image or video data
</ParamField>

<ParamField body="video.keyframes[].generation_id" type="string">
  UUID of a prior completed generation to reuse as the source. Used by ray-3.2 video\_edit / video\_reframe.
</ParamField>

<ParamField body="video.keyframes[].media_type" type="string">
  MIME type. Required with data (and with url for video sources, e.g. video/mp4 on video\_edit / video\_reframe).
</ParamField>

<ParamField body="video.keyframes[].url" type="string">
  Publicly accessible image or video URL
</ParamField>

<ParamField body="video.loop" type="boolean">
  Loop the generated clip. Create-only (type video).
</ParamField>

<ParamField body="video.resolution" type="string">
  Output resolution for ray-3.2 video. Defaults to 720p. 360p is the draft tier. HDR requires 720p or 1080p.

  Possible values: `360p`, `540p`, `720p`, `1080p`
</ParamField>

<ParamField body="video.start_frame" type="object">
  Reference to an image or video. Used for style/content guidance, guided generation, video-edit/video-reframe sources, and guide keyframes. Provide exactly one of generation\_id, url, or data.
</ParamField>

<ParamField body="video.start_frame.data" type="string">
  Base64-encoded image or video data
</ParamField>

<ParamField body="video.start_frame.generation_id" type="string">
  UUID of a prior completed generation to reuse as the source. Used by ray-3.2 video\_edit / video\_reframe.
</ParamField>

<ParamField body="video.start_frame.media_type" type="string">
  MIME type. Required with data (and with url for video sources, e.g. video/mp4 on video\_edit / video\_reframe).
</ParamField>

<ParamField body="video.start_frame.url" type="string">
  Publicly accessible image or video URL
</ParamField>

<ParamField body="web_search" type="boolean">
  Enable web search grounding
</ParamField>

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

### Output

<ResponseField name="created_at" type="string">
  Creation timestamp
</ResponseField>

<ResponseField name="failure_code" type="string">
  Machine-readable failure code for programmatic handling

  Possible values: `content_moderated`, `generation_failed`, `budget_exhausted`, `output_not_found`
</ResponseField>

<ResponseField name="failure_reason" type="string">
  Human-readable failure description, populated only on a FAILED generation. `null` on a successful one.
</ResponseField>

<ResponseField name="id" type="string">
  Generation identifier
</ResponseField>

<ResponseField name="model" type="string">
  Model used
</ResponseField>

<ResponseField name="output" type="object[]">
  A generated output entry
</ResponseField>

<ResponseField name="output[].type" type="string">
  Media type (e.g. image)
</ResponseField>

<ResponseField name="output[].url" type="string">
  Presigned URL (1hr expiry)
</ResponseField>

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

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

<ResponseField name="type" type="string">
  The kind of generation to perform. image/image\_edit are produced by the uni-1 / uni-1-max models; video/video\_edit/video\_reframe are produced by the ray-3.2 model.

  Possible values: `image`, `image_edit`, `video`, `video_edit`, `video_reframe`
</ResponseField>

## Examples

### Input

```json theme={null}
{
  "prompt": "a red circle on a plain white background",
  "type": "image"
}
```

### Output

```json theme={null}
{
  "created_at": "2027-01-01T00:00:00Z",
  "failure_code": null,
  "failure_reason": null,
  "id": "gen-luma-agents-3f2a7c1e8b40",
  "model": "uni-1",
  "output": [
    {
      "type": "image",
      "url": "https://example.invalid/luma_2/uni-1/generated.png"
    }
  ],
  "state": "completed",
  "type": "image"
}
```

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