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

# Kling 모델 라우트 작업 가져오기

> 작업 ID로 Kling 모델 라우트 작업의 상태와 비디오 출력을 가져옵니다.

Kling 모델 라우트 생성 요청 후 이 엔드포인트를 사용하세요. 생성 응답에서 `data.id`을 저장하고 해당 ID를 `task_ids`로 전달하세요.

## 요청 매개변수

| 매개변수 | 필수 | 설명 |
| - | - | - |
| `task_ids` | 예 | 모델 라우트 생성 요청에서 반환되는 작업 ID는 `data.id`. |

하나의 작업을 조회하려면 `<task_id>`을 생성 응답의 `data.id` 값으로 바꾸세요:

```bash theme={null}
task_id="<task_id>"

curl "https://api.cometapi.com/tasks?task_ids=${task_id}" \
  -H "Authorization: Bearer $COMETAPI_KEY"
```

생성 직후 응답에는 제출된 작업이 포함됩니다:

```json theme={null}
{
  "code": 0,
  "message": "SUCCEED",
  "data": [
    {
      "id": "<task_id>",
      "status": "submitted"
    }
  ]
}
```

## 결과 읽기

`data[0]`에서 작업을 읽고 `status`이 종료 상태가 될 때까지 계속 쿼리하세요. 상태가 `succeeded`이면 해당 작업의 `outputs` 배열에서 비디오 URL을 읽으세요. 관찰된 일부 Comet 호환성 응답은 래핑되지 않은 작업 객체를 반환하거나 최상위 `status`을 포함합니다. 이는 표준 envelope가 아닌 호환성 형식입니다. `data`이 있으면 `data[0].status`을 사용하세요.

완료된 작업의 응답 형식은 다음과 같습니다:

```json theme={null}
{
  "code": 0,
  "message": "SUCCEED",
  "data": [
    {
      "id": "<task_id>",
      "status": "succeeded",
      "outputs": [
        {
          "type": "video",
          "url": "https://media.example.com/video.mp4",
          "duration": "5.041"
        }
      ]
    }
  ]
}
```

| 필드 | 설명 |
| - | - |
| `id` | 생성 응답의 작업 ID입니다. |
| `status` | 현재 작업 상태입니다. 종료 상태에 도달할 때까지 계속 쿼리하세요. |
| `message` | 사용 가능한 경우 반환되는 작업 세부 정보입니다. |
| `outputs[].type` | 출력 미디어 유형입니다. 다음을 포함하는 항목을 선택하세요 `type: video`. |
| `outputs[].url` | 작업이 성공하면 다운로드하거나 저장할 비디오 URL입니다. |
| `outputs[].duration` | 반환되는 경우 비디오 길이(초)입니다. |

반환된 URL을 사용할 수 있는 기간 이후에도 보관해야 한다면 완료된 비디오를 자체 스토리지에 저장하세요.


## OpenAPI

````yaml api/openapi/video/kling/model-routes/get-tasks.openapi.json GET /tasks
openapi: 3.1.0
info:
  title: Get a Kling model-route task
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /tasks:
    get:
      summary: Get a Kling task
      description: >-
        Retrieve the status and outputs for a task created through a Kling model
        route by its task ID.
      operationId: getKlingModelRouteTask
      parameters:
        - name: task_ids
          in: query
          required: true
          description: >-
            Task ID from the `data.id` field of a creation response. This
            CometAPI route documents one `task_ids` value per request.
          schema:
            type: string
          example: <task_id>
      responses:
        '200':
          description: >-
            The task state and available outputs are returned in the `data`
            array.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskEnvelope'
              examples:
                Submitted:
                  summary: Submitted task in the data array
                  value:
                    code: 0
                    message: SUCCEED
                    data:
                      - id: <task_id>
                        status: submitted
                Completed:
                  summary: Completed task with a video output
                  value:
                    code: 0
                    message: SUCCEED
                    data:
                      - id: <task_id>
                        status: succeeded
                        outputs:
                          - type: video
                            url: https://media.example.com/video.mp4
                            duration: '5.041'
      x-codeSamples:
        - lang: Shell
          label: Get task
          source: |
            task_id="<task_id>"

            curl "https://api.cometapi.com/tasks?task_ids=${task_id}" \
              -H "Authorization: Bearer $COMETAPI_KEY"
        - lang: Python
          label: Get task
          source: |
            import os
            import requests

            task_id = "<task_id>"
            response = requests.get(
                "https://api.cometapi.com/tasks",
                params={"task_ids": task_id},
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
            )
            response.raise_for_status()
            payload = response.json()
            task = payload.get("data", payload)
            if isinstance(task, list):
                task = task[0]
            print(task["status"], task.get("outputs", []))
        - lang: JavaScript
          label: Get task
          source: |
            const taskId = "<task_id>";
            const url = new URL("https://api.cometapi.com/tasks");
            url.searchParams.set("task_ids", taskId);
            const response = await fetch(url, {
              headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
            });
            if (!response.ok) throw new Error(`HTTP ${response.status}`);
            const payload = await response.json();
            const data = payload.data ?? payload;
            const task = Array.isArray(data) ? data[0] : data;
            console.log(task.status, task.outputs ?? []);
components:
  schemas:
    TaskEnvelope:
      type: object
      required:
        - data
      properties:
        code:
          oneOf:
            - type: integer
            - type: string
          description: Response code returned with the task list.
        message:
          type: string
          description: Response message returned with the task list.
        status:
          type: string
          description: >-
            Observed Comet compatibility response-level status when returned.
            Read the selected task state from `data[0].status`.
        request_id:
          type: string
          description: Request ID for support when returned.
        data:
          type: array
          minItems: 1
          maxItems: 1
          description: >-
            The task record returned for the requested task. The current
            CometAPI route returns it as `data[0]`.
          items:
            $ref: '#/components/schemas/TaskItem'
      description: >-
        Canonical task response for the CometAPI route. Read the selected task
        from `data[0]`; a bare task object is a compatibility form.
    TaskItem:
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          description: Task ID returned when the video task was created.
        status:
          type: string
          description: >-
            Task state, such as `submitted`, `processing`, `succeeded`, or
            `failed`.
        message:
          type: string
          description: Task detail when returned.
        outputs:
          type: array
          description: Generated media when the task returns outputs.
          items:
            type: object
            properties:
              id:
                type: string
                description: Generated output ID when returned.
              type:
                type: string
                description: Output media type, such as `video`.
              url:
                type: string
                format: uri
                description: URL of the generated media.
              duration:
                type: string
                description: Generated media duration in seconds when returned.
        create_time:
          type: integer
          description: Task creation time in Unix milliseconds when returned.
        update_time:
          type: integer
          description: Last task update time in Unix milliseconds when returned.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use your CometAPI API key as a Bearer token.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.