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

# Comfy Router에서 Uni 1 사용하기

> Comfy Router를 통해 luma_2/uni-1 호출하기: 엔드포인트, 요청 형태, 그리고 Router가 반환하는 응답.

Luma 2에서 Comfy Router가 제공하는 `luma_2/uni-1`에 대한 API 레퍼런스입니다.

## 배포 전 확인

SDK는 `Idempotency-Key`를 생성하고 자동 재시도에서 재사용합니다. 수동 재시도 시에는 원래 키를 재사용하세요. Router는 연결을 최대 10분간 유지할 수 있습니다.

요청이 실패하면 Router는 이유를 설명하는 `X-Comfy-Error-Type` 응답 헤더를 보냅니다. `422`는 Router가 프로바이더를 호출하기 전에 입력을 거부했음을 의미합니다. 생성된 에셋은 [결과 URL이 만료](/ko/development/comfy-router/reference#결과-에셋)될 수 있으므로 즉시 다운로드하세요.

<CardGroup cols={3}>
  <Card title="헤더" icon="list" href="/ko/development/comfy-router/quickstart">
    인증, 멱등성, 요청 ID, 오류 분류, 재시도 간격, 지출 한도.
  </Card>

  <Card title="Router API 사용" icon="code" href="/ko/development/comfy-router/quickstart">
    모델 검색, 유효성 검사 오류, 재시도, 과금.
  </Card>

  <Card title="제한 사항" icon="triangle-exclamation" href="/ko/development/comfy-router/limitations">
    Router가 현재 지원하지 않는 기능과 대체 방법.
  </Card>
</CardGroup>

## 빠른 시작

[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:** `luma_2/uni-1`

**엔드포인트:** `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">
    <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>

## 스키마

### 입력

<ParamField body="aspect_ratio" type="string">
  출력 화면 비율입니다. ray-3.2 비디오 모델은 9:16, 3:4, 1:1, 4:3, 16:9, 21:9 하위 집합을 지원합니다.

  가능한 값: `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[]">
  스타일/콘텐츠 가이드를 위한 참조 이미지입니다. type 'image'의 경우 최대 9개, type 'image\_edit'의 경우 최대 8개까지 가능합니다.
</ParamField>

<ParamField body="image_ref[].data" type="string">
  Base64로 인코딩된 이미지 또는 비디오 데이터
</ParamField>

<ParamField body="image_ref[].generation_id" type="string">
  소스로 재사용할 이전에 완료된 생성의 UUID입니다. ray-3.2 video\_edit / video\_reframe에서 사용됩니다.
</ParamField>

<ParamField body="image_ref[].media_type" type="string">
  MIME 타입입니다. data와 함께 필수이며, 비디오 소스의 경우 url과도 함께 필수입니다(예: video\_edit / video\_reframe의 video/mp4).
</ParamField>

<ParamField body="image_ref[].url" type="string">
  공개적으로 접근 가능한 이미지 또는 비디오 URL
</ParamField>

<ParamField body="model" type="string">
  사용할 모델입니다. 이미지 생성에는 uni-1 / uni-1-max, 비디오 생성, 편집, 리프레이밍에는 ray-3.2를 사용합니다.
</ParamField>

<ParamField body="output_format" type="string">
  출력 이미지 형식

  가능한 값: `png`, `jpeg`
</ParamField>

<ParamField body="prompt" type="string" required>
  텍스트 프롬프트
</ParamField>

<ParamField body="source" type="object">
  이미지 또는 비디오에 대한 참조입니다. 스타일/콘텐츠 가이드, 가이드 생성, video-edit/video-reframe 소스, 가이드 키프레임에 사용됩니다. generation\_id, url, data 중 정확히 하나를 제공하세요.
</ParamField>

<ParamField body="source.data" type="string">
  Base64로 인코딩된 이미지 또는 비디오 데이터
</ParamField>

<ParamField body="source.generation_id" type="string">
  소스로 재사용할 이전에 완료된 생성의 UUID입니다. ray-3.2 video\_edit / video\_reframe에서 사용됩니다.
</ParamField>

<ParamField body="source.media_type" type="string">
  MIME 타입입니다. data와 함께 필수이며, 비디오 소스의 경우 url과도 함께 필수입니다(예: video\_edit / video\_reframe의 video/mp4).
</ParamField>

<ParamField body="source.url" type="string">
  공개적으로 접근 가능한 이미지 또는 비디오 URL
</ParamField>

<ParamField body="style" type="string">
  스타일 프리셋

  가능한 값: `auto`, `manga`
</ParamField>

<ParamField body="type" type="string">
  수행할 생성의 종류입니다. image/image\_edit는 uni-1 / uni-1-max 모델에서 생성되며, video/video\_edit/video\_reframe은 ray-3.2 모델에서 생성됩니다.

  가능한 값: `image`, `image_edit`, `video`, `video_edit`, `video_reframe`
</ParamField>

<ParamField body="video" type="object">
  ray-3.2의 비디오 출력 설정입니다. 검증과 과금에 영향을 주는 필드만 여기에 모델링되어 있으며, 추가 필드(edit controls, end\_frame, loop, source\_position)는 변경 없이 Luma로 전달됩니다.
</ParamField>

<ParamField body="video.duration" type="string">
  ray-3.2 video / video\_edit의 클립 재생 시간입니다. 기본값은 5s입니다. HDR 생성(type video)은 5s로 제한됩니다.

  가능한 값: `5s`, `10s`
</ParamField>

<ParamField body="video.exr_export" type="boolean">
  MP4와 함께 EXR 파일을 내보냅니다. hdr가 참이어야 합니다. video\_reframe에서는 거부됩니다.
</ParamField>

<ParamField body="video.hdr" type="boolean">
  HDR로 렌더링합니다. 720p/1080p가 필요합니다. video\_reframe에서는 거부됩니다.
</ParamField>

<ParamField body="video.keyframes" type="object[]">
  가이드 프레임 이미지입니다. 키프레임이 하나이면 type "video" 요청이 단일 키프레임 확장이 되며, 항상 5s 블록 하나로 과금됩니다.
</ParamField>

<ParamField body="video.keyframes[].data" type="string">
  Base64로 인코딩된 이미지 또는 비디오 데이터
</ParamField>

<ParamField body="video.keyframes[].generation_id" type="string">
  소스로 재사용할 이전에 완료된 생성의 UUID입니다. ray-3.2 video\_edit / video\_reframe에서 사용됩니다.
</ParamField>

<ParamField body="video.keyframes[].media_type" type="string">
  MIME 타입입니다. data와 함께 필수이며, 비디오 소스의 경우 url과도 함께 필수입니다(예: video\_edit / video\_reframe의 video/mp4).
</ParamField>

<ParamField body="video.keyframes[].url" type="string">
  공개적으로 접근 가능한 이미지 또는 비디오 URL
</ParamField>

<ParamField body="video.loop" type="boolean">
  생성된 클립을 반복 재생합니다. 생성 시에만 사용 가능합니다(type video).
</ParamField>

<ParamField body="video.resolution" type="string">
  ray-3.2 비디오의 출력 해상도입니다. 기본값은 720p입니다. 360p는 드래프트 등급입니다. HDR은 720p 또는 1080p가 필요합니다.

  가능한 값: `360p`, `540p`, `720p`, `1080p`
</ParamField>

<ParamField body="video.start_frame" type="object">
  이미지 또는 비디오에 대한 참조입니다. 스타일/콘텐츠 가이드, 가이드 생성, video-edit/video-reframe 소스, 가이드 키프레임에 사용됩니다. generation\_id, url, data 중 정확히 하나를 제공하세요.
</ParamField>

<ParamField body="video.start_frame.data" type="string">
  Base64로 인코딩된 이미지 또는 비디오 데이터
</ParamField>

<ParamField body="video.start_frame.generation_id" type="string">
  소스로 재사용할 이전에 완료된 생성의 UUID입니다. ray-3.2 video\_edit / video\_reframe에서 사용됩니다.
</ParamField>

<ParamField body="video.start_frame.media_type" type="string">
  MIME 타입입니다. data와 함께 필수이며, 비디오 소스의 경우 url과도 함께 필수입니다(예: video\_edit / video\_reframe의 video/mp4).
</ParamField>

<ParamField body="video.start_frame.url" type="string">
  공개적으로 접근 가능한 이미지 또는 비디오 URL
</ParamField>

<ParamField body="web_search" type="boolean">
  웹 검색 그라운딩을 활성화합니다
</ParamField>

Router가 `GET /v2/models/luma_2/uni-1/openapi.json`에서 제공하는 스키마에서 생성되었으며, 이는 요청이 공급자에게 도달하기 전에 호출을 검증하는 데 사용하는 것과 동일한 문서입니다.

### 출력

<ResponseField name="created_at" type="string">
  생성 타임스탬프
</ResponseField>

<ResponseField name="failure_code" type="string">
  프로그래밍 방식 처리를 위한 기계 판독 가능한 실패 코드

  가능한 값: `content_moderated`, `generation_failed`, `budget_exhausted`, `output_not_found`
</ResponseField>

<ResponseField name="failure_reason" type="string">
  사람이 읽을 수 있는 실패 설명으로, FAILED 생성에서만 채워집니다. 성공한 경우에는 `null`입니다.
</ResponseField>

<ResponseField name="id" type="string">
  생성 식별자
</ResponseField>

<ResponseField name="model" type="string">
  사용된 모델
</ResponseField>

<ResponseField name="output" type="object[]">
  생성된 출력 항목
</ResponseField>

<ResponseField name="output[].type" type="string">
  미디어 유형 (예: 이미지)
</ResponseField>

<ResponseField name="output[].url" type="string">
  Presigned URL (1시간 후 만료)
</ResponseField>

<ResponseField name="state" type="string">
  생성의 현재 상태

  가능한 값: `queued`, `processing`, `completed`, `failed`
</ResponseField>

<ResponseField name="type" type="string">
  수행할 생성의 종류입니다. image/image\_edit는 uni-1 / uni-1-max 모델이 생성하며, video/video\_edit/video\_reframe은 ray-3.2 모델이 생성합니다.

  가능한 값: `image`, `image_edit`, `video`, `video_edit`, `video_reframe`
</ResponseField>

## 예시

### 입력

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

### 출력

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

## 배포 전 확인

SDK는 `Idempotency-Key`를 생성하고 자동 재시도에서 재사용합니다. 수동 재시도 시에는 원래 키를 재사용하세요. Router는 연결을 최대 10분간 유지할 수 있습니다.

요청이 실패하면 Router는 이유를 설명하는 `X-Comfy-Error-Type` 응답 헤더를 보냅니다. `422`는 Router가 프로바이더를 호출하기 전에 입력을 거부했음을 의미합니다. 생성된 에셋은 [결과 URL이 만료](/ko/development/comfy-router/reference#결과-에셋)될 수 있으므로 즉시 다운로드하세요.

<CardGroup cols={3}>
  <Card title="헤더" icon="list" href="/ko/development/comfy-router/quickstart">
    인증, 멱등성, 요청 ID, 오류 분류, 재시도 간격, 지출 한도.
  </Card>

  <Card title="Router API 사용" icon="code" href="/ko/development/comfy-router/quickstart">
    모델 검색, 유효성 검사 오류, 재시도, 과금.
  </Card>

  <Card title="제한 사항" icon="triangle-exclamation" href="/ko/development/comfy-router/limitations">
    Router가 현재 지원하지 않는 기능과 대체 방법.
  </Card>
</CardGroup>
