> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-willie-des-1087-router-migration-block.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy Router로 Wan 2.5 T2I Preview 사용하기

> Comfy Router를 통해 wan/wan2.5-t2i-preview를 호출합니다: endpoint, 요청 형태, 그리고 Router가 반환하는 응답.

`wan/wan2.5-t2i-preview`에 대한 API 레퍼런스이며, Wan에서 Comfy Router를 통해 제공됩니다.

## 빠른 시작

[Comfy 워크스페이스](https://platform.comfy.org/profile/api-keys)에서 키를 생성한 뒤 `COMFY_API_KEY`로 내보내세요. Python과 TypeScript 스니펫은 Comfy SDK(`pip install comfy-sdk`, `npm install @comfyorg/sdk`)를 사용하며, cURL 스니펫은 동일한 호출을 raw HTTP로 전송합니다.

**모델 ID:** `wan/wan2.5-t2i-preview`

**엔드포인트:** `POST https://api.comfy.org/v2/models/wan/wan2.5-t2i-preview`

<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(
              "wan/wan2.5-t2i-preview",
              {
                  "input": {
                      "prompt": "A single red maple leaf on a plain white background.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "1280*1280",
                  },
              },
          )

      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("wan/wan2.5-t2i-preview", {
        input: {
          prompt: "A single red maple leaf on a plain white background.",
        },
        parameters: {
          n: 1,
          size: "1280*1280",
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/wan/wan2.5-t2i-preview \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"A single red maple leaf on a plain white background.\"}, \"parameters\": {\"n\":1,\"size\":\"1280*1280\"}}"
      ```
    </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(
              "wan/wan2.5-t2i-preview",
              {
                  "input": {
                      "prompt": "A single red maple leaf on a plain white background.",
                  },
                  "parameters": {
                      "n": 1,
                      "size": "1280*1280",
                  },
              },
          )
          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("wan/wan2.5-t2i-preview", {
        input: {
          prompt: "A single red maple leaf on a plain white background.",
        },
        parameters: {
          n: 1,
          size: "1280*1280",
        },
      });
      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/wan/wan2.5-t2i-preview/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"prompt\":\"A single red maple leaf on a plain white background.\"}, \"parameters\": {\"n\":1,\"size\":\"1280*1280\"}}"

      # 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/wan/wan2.5-t2i-preview/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/wan/wan2.5-t2i-preview/requests/$REQUEST_ID \
        -H "X-API-Key: $COMFY_API_KEY"
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## 스키마

### 입력

<ParamField body="input" type="object" required>
  프롬프트 단어 등 기본 정보를 입력합니다.
</ParamField>

<ParamField body="input.negative_prompt" type="string">
  이미지에서 보고 싶지 않은 콘텐츠를 설명하는 반대 프롬프트 단어입니다
</ParamField>

<ParamField body="input.prompt" type="string" required>
  기대하는 이미지 요소와 시각적 특징을 설명하는 긍정 프롬프트 단어입니다. 중국어와 영어를 지원하며, 길이는 800자를 초과할 수 없습니다
</ParamField>

<ParamField body="model" type="string">
  텍스트 기반 이미지 생성에 호출할 모델의 ID입니다. 이 컴포넌트에서는 제약되지 않습니다: Comfy Router가 `POST /v2/models/wan/{model}`의 `{model}` 경로 세그먼트에서 이 값을 채웁니다. `POST /proxy/wan/api/v1/services/aigc/text2image/image-synthesis`에 대한 직접 v1 호출은 반드시 이 값을 제공해야 하며, 허용되는 표기법의 enum은 해당 오퍼레이션 자체의 컴포넌트인 `WanImageGenerationRequest`에 있습니다.
</ParamField>

<ParamField body="parameters" type="object">
  이미지 처리 파라미터
</ParamField>

<ParamField body="parameters.n" type="integer" default="4">
  생성되는 이미지 수입니다. 범위 1-4, 기본값은 4입니다

  범위: `1` \~ `4`
</ParamField>

<ParamField body="parameters.prompt_extend" type="boolean" default="true">
  프롬프트 지능형 재작성을 활성화합니다. 기본값은 참입니다
</ParamField>

<ParamField body="parameters.seed" type="integer">
  무작위성을 제어하는 난수 시드입니다. 범위 \[0, 2147483647]

  범위: `0` \~ `2147483647`
</ParamField>

<ParamField body="parameters.size" type="string" default="&#x22;1280*1280&#x22;">
  출력 이미지 해상도로, 너비*높이 형식입니다. 기본값은 1280*1280입니다. API는 1638400(1280*1280)에서 2073600(1440*1440) 사이의 픽셀 면적과 1:4에서 4:1 사이의 비율을 허용하므로 768\*2700도 유효합니다
</ParamField>

<ParamField body="parameters.watermark" type="boolean" default="false">
  오른쪽 아래 모서리에 워터마크 로고를 추가할지 여부
</ParamField>

Router가 `GET /v2/models/wan/wan2.5-t2i-preview/openapi.json`에서 제공하는 스키마에서 생성되었으며, 이는 요청이 공급자에게 도달하기 이전에 호출을 검증하는 동일한 문서입니다.

### 출력

<ResponseField name="output" type="object" required />

<ResponseField name="output.actual_prompt" type="string">
  지능형 재작성 이후의 실제 프롬프트 (비디오 작업용)
</ResponseField>

<ResponseField name="output.check_audio" type="string">
  오디오 생성 기능이 있는 I2V 작업의 오디오 URL
</ResponseField>

<ResponseField name="output.code" type="string">
  실패한 요청의 오류 코드 (요청이 성공하면 반환되지 않음)
</ResponseField>

<ResponseField name="output.end_time" type="string">
  작업 완료 시간
</ResponseField>

<ResponseField name="output.message" type="string">
  실패한 요청에 대한 상세 정보 (요청이 성공하면 반환되지 않음)
</ResponseField>

<ResponseField name="output.orig_prompt" type="string">
  원본 입력 프롬프트 (비디오 작업용)
</ResponseField>

<ResponseField name="output.results" type="object[]">
  이미지 생성 작업의 작업 결과 목록
</ResponseField>

<ResponseField name="output.results[].actual_prompt" type="string">
  지능형 재작성 이후의 실제 프롬프트 (활성화된 경우)
</ResponseField>

<ResponseField name="output.results[].code" type="string">
  이미지 오류 코드 (일부 작업이 실패할 때 반환됨)
</ResponseField>

<ResponseField name="output.results[].message" type="string">
  이미지 오류 정보 (일부 작업이 실패할 때 반환됨)
</ResponseField>

<ResponseField name="output.results[].orig_prompt" type="string">
  원본 입력 프롬프트
</ResponseField>

<ResponseField name="output.results[].url" type="string">
  생성된 이미지 URL 주소
</ResponseField>

<ResponseField name="output.scheduled_time" type="string">
  작업 실행 시간
</ResponseField>

<ResponseField name="output.submit_time" type="string">
  작업 제출 시간
</ResponseField>

<ResponseField name="output.task_id" type="string" required>
  작업 ID
</ResponseField>

<ResponseField name="output.task_metrics" type="object">
  이미지 생성 작업의 작업 결과 통계
</ResponseField>

<ResponseField name="output.task_metrics.FAILED" type="integer">
  실패한 작업 수
</ResponseField>

<ResponseField name="output.task_metrics.SUCCEEDED" type="integer">
  성공한 작업 수
</ResponseField>

<ResponseField name="output.task_metrics.TOTAL" type="integer">
  전체 작업 수
</ResponseField>

<ResponseField name="output.task_status" type="string" required>
  작업 상태

  가능한 값: `PENDING`, `RUNNING`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNKNOWN`
</ResponseField>

<ResponseField name="output.video_url" type="string">
  완료된 비디오 생성 작업의 비디오 URL. 링크 유효 기간은 24시간입니다
</ResponseField>

<ResponseField name="request_id" type="string" required>
  고유 요청 식별자
</ResponseField>

<ResponseField name="usage" type="object">
  출력 정보 통계. 성공한 결과만 집계됩니다
</ResponseField>

<ResponseField name="usage.SR" type="integer">
  비디오 해상도 등급 (I2V 및 wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.duration" type="number">
  생성된 비디오의 재생 시간(초) (I2V 및 wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.fps" type="integer">
  생성된 비디오의 프레임 레이트 (wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.image_count" type="integer">
  생성된 이미지 수 (T2I 및 I2I 작업)
</ResponseField>

<ResponseField name="usage.input_video_duration" type="number">
  입력 비디오의 재생 시간(초), 비디오 입력이 없으면 0.0 (wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.output_video_duration" type="number">
  출력 비디오의 재생 시간(초) (wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.ratio" type="string">
  생성된 비디오의 화면 비율, 예: 16:9 (wan3.0-video 작업)
</ResponseField>

<ResponseField name="usage.size" type="string">
  이미지 해상도 (T2I 및 I2I 작업)
</ResponseField>

<ResponseField name="usage.video_count" type="integer">
  생성된 비디오 수 (T2V 작업)
</ResponseField>

<ResponseField name="usage.video_duration" type="number">
  생성된 비디오의 재생 시간(초) (T2V 작업)
</ResponseField>

<ResponseField name="usage.video_ratio" type="string">
  비디오 해상도 비율 (T2V 작업)
</ResponseField>

<ResponseField name="code" type="string">
  실패한 요청의 오류 코드로, `output` 아래가 아니라 envelope의 ROOT에서 보고됩니다 (요청이 성공하면 반환되지 않음).
</ResponseField>

<ResponseField name="message" type="string">
  실패한 요청에 대한 상세 정보로, `output` 아래가 아니라 envelope의 ROOT에서 보고됩니다 (요청이 성공하면 반환되지 않음). `output.message`로 넘어가기 전에 이 값을 먼저 확인하세요.
</ResponseField>

## 예시

### 입력

```json theme={null}
{
  "input": {
    "prompt": "A single red maple leaf on a plain white background."
  },
  "parameters": {
    "n": 1,
    "size": "1280*1280"
  }
}
```

### 출력

```json theme={null}
{
  "output": {
    "end_time": "2027-01-01T00:00:12.000Z",
    "results": [
      {
        "actual_prompt": "a single red maple leaf resting on still water, shallow depth of field, soft morning light",
        "orig_prompt": "a single red maple leaf resting on still water",
        "url": "https://example.invalid/wan/generated-1.png"
      },
      {
        "code": "DataInspectionFailed",
        "message": "This candidate was rejected; the task as a whole succeeded.",
        "orig_prompt": "a single red maple leaf resting on still water"
      }
    ],
    "scheduled_time": "2027-01-01T00:00:01.000Z",
    "submit_time": "2027-01-01T00:00:00.000Z",
    "task_id": "0385dc79-5ff8-4d82-bcb6-7c1a9f2e4d60",
    "task_metrics": {
      "FAILED": 1,
      "SUCCEEDED": 1,
      "TOTAL": 2
    },
    "task_status": "SUCCEEDED"
  },
  "request_id": "7574ee8f-38a3-4b1e-9280-11c33ab46e51",
  "usage": {
    "image_count": 1,
    "size": "1280*1280"
  }
}
```

## 배포 전 확인

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

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

위의 필드 설명에 명시된 크기 제한은 해당 필드에 대한 공급자 자체의 한도이며, 공급자 사양에서 인용한 것입니다. Router는 전체 요청 본문에 별도의 상한을 적용하며, base64로 인코딩된 미디어도 여기에 포함됩니다. [요청 본문 크기](/ko/development/comfy-router/limitations)를 참고하세요.

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

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

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