> ## 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로 Qwen Image 3.0 사용하기

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

`qwen/qwen-image-3.0`에 대한 API 레퍼런스이며, Qwen에서 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 스니펫은 동일한 호출을 순수 HTTP로 수행한 것입니다.

**모델 ID:** `qwen/qwen-image-3.0`

**엔드포인트:** `POST https://api.comfy.org/v2/models/qwen/qwen-image-3.0`

<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(
              "qwen/qwen-image-3.0",
              {
                  "input": {
                      "messages": [
                          {
                              "content": [
                                  {
                                      "text": "A single red maple leaf on a plain white background.",
                                  },
                              ],
                              "role": "user",
                          },
                      ],
                  },
              },
          )

      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("qwen/qwen-image-3.0", {
        input: {
          messages: [
            {
              content: [
                {
                  text: "A single red maple leaf on a plain white background.",
                },
              ],
              role: "user",
            },
          ],
        },
      });

      console.log(data);
      ```

      ```bash cURL theme={null}
      curl https://api.comfy.org/v2/models/qwen/qwen-image-3.0 \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"messages\":[{\"content\":[{\"text\":\"A single red maple leaf on a plain white background.\"}],\"role\":\"user\"}]}}"
      ```
    </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(
              "qwen/qwen-image-3.0",
              {
                  "input": {
                      "messages": [
                          {
                              "content": [
                                  {
                                      "text": "A single red maple leaf on a plain white background.",
                                  },
                              ],
                              "role": "user",
                          },
                      ],
                  },
              },
          )
          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("qwen/qwen-image-3.0", {
        input: {
          messages: [
            {
              content: [
                {
                  text: "A single red maple leaf on a plain white background.",
                },
              ],
              role: "user",
            },
          ],
        },
      });
      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/qwen/qwen-image-3.0/requests \
        -H "X-API-Key: $COMFY_API_KEY" \
        -H "Idempotency-Key: $(uuidgen)" \
        -H "Content-Type: application/json" \
        -d "{\"input\": {\"messages\":[{\"content\":[{\"text\":\"A single red maple leaf on a plain white background.\"}],\"role\":\"user\"}]}}"

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

## 스키마

### 입력

<ParamField body="input" type="object" required>
  요청 메시지를 담는 입력 파라미터 객체
</ParamField>

<ParamField body="input.messages" type="object[]" required>
  요청 콘텐츠 배열. 단일 턴 대화만 지원하므로 배열에는 정확히 하나의 객체만 포함되어야 합니다
</ParamField>

<ParamField body="input.messages[].content" type="object[]" required>
  메시지 콘텐츠 배열. 텍스트 기반 이미지 생성은 텍스트 객체 하나를, 이미지 편집은 이미지 객체 1-3개와 텍스트 객체 하나를 포함합니다
</ParamField>

<ParamField body="input.messages[].content[].image" type="string">
  입력 이미지의 URL 또는 Base64 인코딩 데이터. 이미지 편집 시 1-3개의 이미지를 지원합니다
</ParamField>

<ParamField body="input.messages[].content[].text" type="string">
  생성하거나 편집할 이미지의 콘텐츠, 스타일, 구도를 설명하는 긍정 프롬프트
</ParamField>

<ParamField body="input.messages[].role" type="string" required>
  메시지 발신자의 역할. user로 설정해야 합니다

  사용 가능한 값: `user`
</ParamField>

<ParamField body="model" type="string">
  멀티모달 이미지 생성 및 편집을 위해 호출할 모델의 ID. 사용 가능한 값은 qwen-image-3.0-pro와 qwen-image-3.0입니다. 이 스키마의 `required` 목록에 없는 이유는 Comfy Router가 /v2/models/qwen/\{model} 경로 세그먼트의 `{model}`에서 이 값을 채우기 때문이며, 따라서 Router 호출자는 이를 생략합니다. /proxy/ 경로에 대한 직접 v1 호출은 반드시 이 값을 제공해야 합니다.
</ParamField>

<ParamField body="parameters" type="object">
  이미지 생성을 제어하는 추가 파라미터
</ParamField>

<ParamField body="parameters.n" type="integer" default="1">
  출력 이미지 수. 범위 1-6, 기본값은 1

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

<ParamField body="parameters.negative_prompt" type="string">
  이미지에 나타나지 않기를 원하는 콘텐츠를 설명하는 네거티브 프롬프트
</ParamField>

<ParamField body="parameters.prompt_extend" type="boolean" default="true">
  지능형 프롬프트 재작성 사용 여부. 기본값은 참
</ParamField>

<ParamField body="parameters.prompt_extend_mode" type="string" default="&#x22;direct&#x22;">
  프롬프트 재작성 방법으로, direct(기본값, T2I 및 I2I 지원) 또는 agent(T2I만 해당)

  사용 가능한 값: `direct`, `agent`
</ParamField>

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

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

<ParamField body="parameters.size" type="string">
  width*height 형식의 출력 이미지 해상도입니다. 예: 1024*1024. API는 262144(512*512)에서 6553600(2560*2560) 사이의 픽셀 면적과 1:8에서 8:1 사이의 비율을 허용합니다. 지정하지 않으면 모델이 프롬프트를 기반으로 해상도를 자동으로 추천합니다
</ParamField>

<ParamField body="parameters.watermark" type="boolean" default="false">
  워터마크 추가 여부. 기본값은 거짓
</ParamField>

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

### 출력

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

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

<ResponseField name="output" type="object">
  모델 생성 결과를 포함합니다
</ResponseField>

<ResponseField name="output.choices" type="object[]">
  결과 옵션 목록
</ResponseField>

<ResponseField name="output.choices[].finish_reason" type="string">
  작업이 중단된 이유. 작업이 정상적으로 완료되면 값은 stop입니다
</ResponseField>

<ResponseField name="output.choices[].message" type="object">
  모델이 반환한 메시지
</ResponseField>

<ResponseField name="output.choices[].message.content" type="object[]">
  생성된 이미지 정보를 담은 메시지 콘텐츠
</ResponseField>

<ResponseField name="output.choices[].message.content[].image" type="string">
  생성된 PNG 형식 이미지의 URL. 링크는 24시간 동안 유효합니다
</ResponseField>

<ResponseField name="output.choices[].message.content[].text" type="string">
  이미지 대신 반환되는 텍스트 요소. 이 필드만 담은 요소는 어떤 에셋도 생성하지 않았으므로, 호출자는 콘텐츠 요소의 존재 여부가 아니라 `image`를 기준으로 완료를 판단합니다
</ResponseField>

<ResponseField name="output.choices[].message.role" type="string">
  메시지의 역할. assistant로 고정됩니다
</ResponseField>

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

<ResponseField name="usage" type="object">
  이 호출의 리소스 사용량. 성공한 경우에만 반환됩니다
</ResponseField>

<ResponseField name="usage.input_image_count" type="integer">
  요청에 포함된 입력 이미지 수. 텍스트 기반 이미지 생성의 경우 0을 반환합니다
</ResponseField>

<ResponseField name="usage.input_image_type" type="string">
  입력 이미지 과금 등급으로 qima\_input\_1k 또는 qima\_input\_2k이며, 출력 해상도의 픽셀 면적에 따라 결정됩니다
</ResponseField>

<ResponseField name="usage.output_height" type="integer">
  최종 출력 이미지의 높이(픽셀)
</ResponseField>

<ResponseField name="usage.output_image_count" type="integer">
  실제로 반환된 출력 이미지 수
</ResponseField>

<ResponseField name="usage.output_image_type" type="string">
  출력 이미지 과금 등급으로 qima\_output\_1k 또는 qima\_output\_2k이며, 출력 해상도의 픽셀 면적에 따라 결정됩니다
</ResponseField>

<ResponseField name="usage.output_width" type="integer">
  최종 출력 이미지의 너비(픽셀)
</ResponseField>

## 예시

### 입력

```json theme={null}
{
  "input": {
    "messages": [
      {
        "content": [
          {
            "text": "A single red maple leaf on a plain white background."
          }
        ],
        "role": "user"
      }
    ]
  }
}
```

### 출력

```json theme={null}
{
  "output": {
    "choices": [
      {
        "finish_reason": "stop",
        "message": {
          "content": [
            {
              "image": "https://example.invalid/qwen/generated.png"
            }
          ],
          "role": "assistant"
        }
      }
    ]
  },
  "request_id": "9f2c1b3a-5d4e-4a67-8b90-1c2d3e4f5a6b",
  "usage": {
    "input_image_count": 0,
    "output_height": 512,
    "output_image_count": 1,
    "output_image_type": "qima_output_1k",
    "output_width": 512
  }
}
```

## 배포 전 확인

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>
