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

# Truy xuất một video Veo 3

> Sử dụng API CometAPI Veo3 Retrieve (GET /v1/videos/{video_id}) để lấy trạng thái, truy vấn metadata hoặc tải xuống kết quả tạo video Veo3 theo video_id.

Sử dụng endpoint này để poll một job Veo. Endpoint này trả về trạng thái tác vụ hiện tại và thông tin model của provider đã được phân giải.

## Vòng lặp polling

<Steps>
  <Step title="Tạo job trước">
    Bắt đầu với [Veo3 Async Generation](./create) và lưu `id` được trả về.
  </Step>

  <Step title="Poll cho đến khi tác vụ ở trạng thái kết thúc">
    Tiếp tục gọi endpoint này cho đến khi job không còn ở `queued` hoặc `in_progress` và đạt đến trạng thái hoàn tất.
  </Step>

  <Step title="Lưu kết quả">
    Khi output đã sẵn sàng, hãy chuyển nó vào hệ thống lưu trữ của riêng bạn nếu ứng dụng của bạn cần một bản sao bền vững.
  </Step>
</Steps>

## Vì sao model ID có thể thay đổi

Phản hồi có thể hiển thị model ID của provider đã được phân giải thay vì alias bạn đã gửi. Đây là hành vi bình thường.


## OpenAPI

````yaml api/openapi/video/veo3/get-retrieve.openapi.json GET /v1/videos/{video_id}
openapi: 3.1.0
info:
  title: Veo3 Retrieve API
  version: 1.0.0
  description: >-
    Retrieve the current state of a Veo job created through the CometAPI
    /v1/videos route.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos/{video_id}:
    get:
      summary: Retrieve a Veo video job
      description: >-
        Poll a Veo job created through CometAPI. The response may include a
        resolved provider model ID instead of the alias you submitted.
      operationId: veo3_retrive
      parameters:
        - name: video_id
          in: path
          required: true
          description: Task id returned by the create endpoint.
          schema:
            type: string
      responses:
        '200':
          description: Current job state.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - size
                  - model
                  - object
                  - status
                  - progress
                  - created_at
                properties:
                  id:
                    type: string
                  size:
                    type: string
                  model:
                    type: string
                  object:
                    type: string
                  status:
                    type: string
                  task_id:
                    type: string
                  progress:
                    type: integer
                  created_at:
                    type: integer
                example:
                  id: task_pa9CKKtYlTdxO7IIHOKKhXfjxEu4EQoR
                  size: 16x9
                  model: veo_3_1-4K
                  object: video
                  status: queued
                  task_id: task_pa9CKKtYlTdxO7IIHOKKhXfjxEu4EQoR
                  progress: 0
                  created_at: 1773297229
              example:
                id: <video_id>
                object: video
                model: veo3.1-fast
                status: completed
                progress: '100'
                created_at: '1781079479'
                completed_at: '1781079580'
                video_url: >-
                  https://comet-api-bucket.s3.us-east-1.amazonaws.com/videos/<video_id>.mp4?...
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            VIDEO_ID="<video_id>"

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

            while true; do
              STATUS=$(curl -s "https://api.cometapi.com/v1/videos/$VIDEO_ID" \
                -H "Authorization: Bearer $COMETAPI_KEY" | python3 -c "import json,sys; print(json.load(sys.stdin)['status'])")
              echo "status: $STATUS"
              case "$STATUS" in completed | failed) break;; esac
              sleep 20
            done
        - lang: Python
          label: Default
          source: |
            import os
            import requests

            video_id = "<video_id>"

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

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

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

            while True:
                video = requests.get(
                    f"https://api.cometapi.com/v1/videos/{video_id}", headers=headers
                ).json()
                print(video["status"], video.get("progress"))
                if video["status"] in ("completed", "failed"):
                    break
                time.sleep(20)

            if video["status"] == "completed":
                print(video["video_url"])
        - lang: JavaScript
          label: Default
          source: >
            const videoId = "<video_id>";


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


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

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


            let video;

            while (true) {
                video = await (await fetch(`https://api.cometapi.com/v1/videos/${videoId}`, { headers })).json();
                console.log(video.status, video.progress);
                if (video.status === "completed" || video.status === "failed") break;
                await new Promise((resolve) => setTimeout(resolve, 20000));
            }


            if (video.status === "completed") console.log(video.video_url);
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````