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

# Tải xuống nội dung video Sora 2

> Lấy dữ liệu nhị phân của video Sora 2 đã tạo qua GET /v1/videos/{video_id}/content trong CometAPI để tải xuống đầu ra video đã hoàn tất theo video_id.

Sử dụng endpoint này để tải xuống đầu ra Sora đã hoàn tất sau khi tác vụ đạt trạng thái `completed`. Trước đó, endpoint sẽ trả về lỗi thay vì tệp video.

## Trước khi tải xuống

* Chờ đến khi [Retrieve Video](./retrieve) báo `status: completed`
* Truyền `video_id` từ bước tạo
* Lưu trữ tệp trong bucket hoặc CDN của riêng bạn nếu bạn cần giữ tệp lâu hơn khoảng thời gian phân phối tạm thời của nhà cung cấp

## Quy trình tải xuống

<Steps>
  <Step title="Tạo video">
    Bắt đầu với [Create Video](./create).
  </Step>

  <Step title="Thăm dò cho đến khi hoàn tất">
    Sử dụng [Retrieve Video](./retrieve) cho đến khi tác vụ đạt `completed`.
  </Step>

  <Step title="Lấy tệp nhị phân">
    Gọi endpoint này để tải xuống MP4 hoặc biến thể tài nguyên được hỗ trợ khác.
  </Step>
</Steps>

## Khoảng thời gian phân phối tạm thời

Sau khi quá trình render hoàn tất, hãy lấy tệp ngay. URL phân phối của nhà cung cấp không phải là vĩnh viễn.


## OpenAPI

````yaml api/openapi/video/sora-2/get-retrieve-content.openapi.json GET /v1/videos/{video_id}/content
openapi: 3.1.0
info:
  title: Retrieve Video Content API
  version: 1.0.0
  description: >-
    Download the finished Sora asset for a completed video job. The endpoint
    returns binary content on success and a JSON error if the job is not ready.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos/{video_id}/content:
    get:
      summary: Download finished Sora video content
      description: >-
        Call this endpoint only after GET /v1/videos/{video_id} reports a
        completed job. Before completion, CometAPI returns a JSON error response
        instead of a file. Shortly after completion the file can still be
        propagating; a transient `502` from this endpoint resolves on retry.
      operationId: retrieve_video_content
      parameters:
        - name: video_id
          in: path
          required: true
          description: Completed video id.
          schema:
            type: string
        - name: variant
          in: query
          required: false
          description: >-
            Optional content variant such as the main video, thumbnail, or
            spritesheet when supported by the provider.
          schema:
            type: string
      responses:
        '200':
          description: Binary video content.
          content:
            video/mp4:
              schema:
                type: string
                format: binary
        '400':
          description: The job is not ready yet.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - message
                      - type
                    properties:
                      message:
                        type: string
                      type:
                        type: string
                example:
                  error:
                    message: 'Task is not completed yet, current status: IN_PROGRESS'
                    type: invalid_request_error
      x-codeSamples:
        - lang: Shell
          label: Default
          source: |
            VIDEO_ID="<video_id>"

            curl -L "https://api.cometapi.com/v1/videos/$VIDEO_ID/content" \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -o video.mp4
        - 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}/content",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
            )
            response.raise_for_status()

            with open("video.mp4", "wb") as f:
                f.write(response.content)
        - lang: JavaScript
          label: Default
          source: >
            import { writeFile } from "node:fs/promises";


            const videoId = "<video_id>";


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


            await writeFile("video.mp4", Buffer.from(await
            response.arrayBuffer()));
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````