> ## 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.

# Lấy một tác vụ Runway

> Sử dụng CometAPI để gọi GET /runwayml/v1/tasks/{id} và lấy trạng thái, tiến độ, đầu ra và siêu dữ liệu của tác vụ tạo video Runway theo ID tác vụ.

Sử dụng endpoint này để kiểm tra một tác vụ Runway theo id.

## Kiểm tra các trường này trước

* `id` cho mã định danh tác vụ
* `status` cho trạng thái hiện tại của tác vụ
* `output` cho các URL tài nguyên đã hoàn tất khi tác vụ thành công
* `failure` và `failureCode` khi tác vụ thất bại

## Khi nào nên sử dụng

* Sau khi gọi một trang tạo tác vụ Runway theo định dạng chính thức như text-to-image, image-to-video hoặc video-to-video

## Hành vi thử lại

* Một tác vụ vừa được tạo có thể tạm thời trả về `task_not_exist`
* Chờ vài giây và thử lại trước khi coi id tác vụ là không hợp lệ
* Khi tác vụ đã hiển thị, tiếp tục polling endpoint này cho đến khi nó trả về trạng thái kết thúc hoặc đầu ra hoàn tất.


## OpenAPI

````yaml api/openapi/video/runway/official-format/get-runway-to-get-task-details.openapi.json GET /runwayml/v1/tasks/{id}
openapi: 3.1.0
info:
  title: Get Task Details API
  version: 1.0.0
  description: Poll a Runway official-format task through CometAPI and read the task state.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /runwayml/v1/tasks/{id}:
    get:
      summary: Poll a Runway official-format task
      description: >-
        Use the task id returned by an official-format Runway create endpoint.
        Fresh task ids can briefly return `task_not_exist` before the system
        begins returning task state. Output URLs are time-limited; download
        promptly and mirror to your own storage.
      operationId: runway_to_get_task_details
      parameters:
        - name: id
          in: path
          required: true
          description: Runway task id returned by the create endpoint.
          schema:
            type: string
        - name: X-Runway-Version
          in: header
          required: false
          description: Optional Runway version header, for example `2024-11-06`.
          schema:
            type: string
      responses:
        '200':
          description: Current task state.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - status
                properties:
                  id:
                    type: string
                    description: Task ID.
                  status:
                    type: string
                    description: Task status.
                    enum:
                      - PENDING
                      - RUNNING
                      - SUCCEEDED
                      - FAILED
                  createdAt:
                    type: string
                    description: Task creation timestamp.
                  output:
                    type: array
                    description: Output URLs returned after the task succeeds.
                    items:
                      type: string
                  failure:
                    type: string
                    description: Failure reason returned after the task fails.
                  failureCode:
                    type: string
                    description: Failure code returned after the task fails.
                  progress:
                    type: number
                    description: Task progress.
                additionalProperties: true
                example:
                  id: d0658ae1-bbdd-4adc-aaba-fd8070e14d79
                  status: SUCCEEDED
                  createdAt: '2026-05-01T12:47:47.351Z'
                  output:
                    - https://example.com/output.mp4
              examples:
                Succeeded:
                  summary: Finished task with output URLs
                  value:
                    id: <task_id>
                    status: SUCCEEDED
                    createdAt: '2026-06-10T08:45:00.000Z'
                    output:
                      - https://<provider-cdn>/<file_id>.png
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            TASK_ID="<task_id>"

            curl "https://api.cometapi.com/runwayml/v1/tasks/$TASK_ID" \
              -H "Authorization: Bearer $COMETAPI_KEY"
        - lang: Shell
          label: Poll until done
          source: |
            TASK_ID="<task_id>"

            while true; do
              STATUS=$(curl -s "https://api.cometapi.com/runwayml/v1/tasks/$TASK_ID" \
                -H "Authorization: Bearer $COMETAPI_KEY" | python3 -c "import json,sys; print(json.load(sys.stdin).get('status','PENDING'))")
              echo "status: $STATUS"
              case "$STATUS" in SUCCEEDED | FAILED) break;; esac
              sleep 10
            done
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            task_id = "<task_id>"

            response = requests.get(
                f"https://api.cometapi.com/runwayml/v1/tasks/{task_id}",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
            )

            print(response.json())
        - lang: Python
          label: Poll until done
          source: |
            import os
            import time
            import requests

            task_id = "<task_id>"
            headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}

            while True:
                task = requests.get(
                    f"https://api.cometapi.com/runwayml/v1/tasks/{task_id}", headers=headers
                ).json()
                print(task.get("status"))
                if task.get("status") in ("SUCCEEDED", "FAILED") or task.get("output"):
                    break
                time.sleep(10)

            print(task.get("output"))
        - lang: JavaScript
          label: Default
          source: >
            const taskId = "<task_id>";


            const response = await
            fetch(`https://api.cometapi.com/runwayml/v1/tasks/${taskId}`, {
                headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
            });


            console.log(await response.json());
        - lang: JavaScript
          label: Poll until done
          source: >
            const taskId = "<task_id>";

            const headers = { Authorization: `Bearer
            ${process.env.COMETAPI_KEY}` };


            let task;

            while (true) {
                task = await (await fetch(`https://api.cometapi.com/runwayml/v1/tasks/${taskId}`, { headers })).json();
                console.log(task.status);
                if (task.status === "SUCCEEDED" || task.status === "FAILED" || task.output) break;
                await new Promise((resolve) => setTimeout(resolve, 10000));
            }


            console.log(task.output);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````