> ## Documentation Index
> Fetch the complete documentation index at: https://comfyuiwiki.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router 빠른 시작

> 최신 프런티어 미디어 모델로 몇 분 만에 이미지와 비디오를 생성하세요.

<div className="router-quickstart-marker" />

Comfy Router는 `https://api.comfy.org`에서 호스팅되는 이미지 및 비디오 모델을 위한 단일 API를 제공합니다. [Comfy 워크스페이스](https://platform.comfy.org/profile/api-keys?onboarding=router)에서 API 키를 생성한 다음, 공식 [Python 및 TypeScript SDK](/ko/development/api-development/sdks) 또는 일반 HTTP로 모든 모델을 호출하세요. 과금은 사용한 만큼 지불하는 방식입니다. 각 요청은 구독 없이 워크스페이스 잔액에서 크레딧을 차감합니다.

<Note>
  **Higgsfield를 사용 중이신가요?** 자신의 Higgsfield 키를 저장하면 해당 생성은 Comfy 크레딧 대신 Higgsfield 계정에 청구됩니다. 엔드포인트와 요청 본문은 동일합니다. 자세한 내용은 [자신의 키로 Higgsfield 사용](/ko/development/comfy-router/higgsfield-byok)을 참고하세요.
</Note>

<Steps titleSize="h2">
  <Step title="API 키 생성">
    [Comfy 워크스페이스](https://platform.comfy.org/profile/api-keys?onboarding=router)에서 키를 생성하세요. Bash 호환 터미널에서 다음을 설정합니다:

    ```bash theme={null}
    export COMFY_API_KEY="comfyui-..."
    ```

    API 키는 서버나 로컬 환경에 보관하세요. 이 예시는 터미널 또는 서버용이며, 브라우저 JavaScript용이 아닙니다.

    Router는 요청마다 크레딧을 차감합니다. 워크스페이스에 크레딧 잔액이 없으면 첫 실제 호출에서 `error_type: insufficient_credits`와 함께 `402`가 반환됩니다. 이 검사는 본문 검증 이전에 실행되므로, 크레딧이 없는 워크스페이스는 잘못된 요청에 대해서도 `402`를 반환할 수 있습니다. 요청 본문을 디버깅하기 전에 [워크스페이스 결제](https://platform.comfy.org)에서 크레딧을 추가하세요.
  </Step>

  <Step title="요청 실행 대기열에 넣기">
    언어를 선택하고 예시를 실행하세요. 생성에는 몇 분이 걸릴 수 있습니다.

    <CodeGroup>
      ```python Python theme={null}
      # Python 3.10+
      # 설치: python -m pip install "comfy-sdk>=0.3.0"
      # quickstart.py로 저장한 뒤 실행: python quickstart.py

      import asyncio

      from comfy_sdk import AsyncComfy

      # AsyncComfy는 환경 변수에서 COMFY_API_KEY를 읽습니다.
      async def main():
          async with AsyncComfy() as client:
              handle = await client.models.submit(
                  "byteplus/dreamina-seedance-2-5-260628",
                  {
                      "content": [
                          {
                              "text": "A red fox trotting through a snowy pine forest",
                              "type": "text",
                          },
                      ],
                      "duration": 5,
                      "ratio": "16:9",
                      "resolution": "720p",
                  },
              )
              print("request_id:", handle.request_id)

              # 요청이 완료될 때까지 폴링하며, 서버가 알려준 Retry-After만큼 대기합니다.
              async for update in handle.iter_events():
                  print(update.status, update.queue_position)

              result = await handle.get()

          print("result:", result)

      asyncio.run(main())
      ```

      ```bash cURL theme={null}
      # 1. 요청을 제출합니다. 201 응답에서 request_id를 저장하세요.
      curl https://api.comfy.org/v2/models/byteplus/dreamina-seedance-2-5-260628/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d '{"content": [{"text": "A red fox trotting through a snowy pine forest", "type": "text"}], "duration": 5, "ratio": "16:9", "resolution": "720p"}'

      # 2. 상태가 COMPLETED가 될 때까지 폴링하며, 매번 Retry-After 값만큼 대기합니다.
      REQUEST_ID="paste-request-id-from-201-response"
      curl -i "https://api.comfy.org/v2/models/byteplus/dreamina-seedance-2-5-260628/requests/$REQUEST_ID/status" \
        -H "X-API-Key: $COMFY_API_KEY"

      # 3. 모델 결과를 수집합니다.
      curl "https://api.comfy.org/v2/models/byteplus/dreamina-seedance-2-5-260628/requests/$REQUEST_ID" \
        -H "X-API-Key: $COMFY_API_KEY"
      ```

      ```typescript TypeScript theme={null}
      // Node.js 22+
      // 설치: npm install "@comfyorg/sdk@>=0.4.0" --save-dev tsx
      // quickstart.mts로 저장한 뒤 실행: npx tsx quickstart.mts

      import { comfy } from "@comfyorg/sdk";

      // Comfy는 환경 변수에서 COMFY_API_KEY를 읽습니다.
      const handle = await comfy.models.submit(
        "byteplus/dreamina-seedance-2-5-260628",
        {
          content: [
            {
              text: "A red fox trotting through a snowy pine forest",
              type: "text",
            },
          ],
          duration: 5,
          ratio: "16:9",
          resolution: "720p",
        },
      );
      console.log("requestId:", handle.requestId);

      // 요청이 완료될 때까지 폴링하며, 서버가 알려준 Retry-After만큼 대기합니다.
      for await (const update of handle.events()) {
        console.log(update.status, update.queuePosition);
      }

      const result = await handle.get();

      console.log("result:", result.data);
      ```
    </CodeGroup>

    각 SDK submit 호출은 멱등성 키를 생성하고 자동 재시도에 재사용합니다.
    cURL 예시는 `uuidgen`으로 키를 하나 생성합니다. `uuidgen`을 사용할 수 없다면 다른 UUID 생성기를 사용하세요.
    상태, 취소, 결과 수집에 대한 세부 정보는 [대기 중 전송](/ko/development/comfy-router/queue)을 참고하세요.
  </Step>
</Steps>
