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

# Получение видео Sora 2

> Используйте CometAPI GET /v1/videos/{video_id}, чтобы получить статус видео Sora 2, прогресс и метаданные, такие как длительность, размеры, временные метки и срок действия.

Используйте этот endpoint после запуска задания Sora. Он сообщает текущее состояние задания, настроенные размер и длительность, а также любую ошибку, возвращённую провайдером.

## Обратите внимание на эти поля

* `status` для состояния жизненного цикла
* `progress` для грубого сигнала о прогрессе
* `error`, если провайдер отклоняет задание или при его выполнении происходит сбой
* `expires_at` после завершения, если вам нужно знать, когда истекает срок действия временных ресурсов

## Опрос до завершения

<Steps>
  <Step title="Сначала создайте видео">
    Начните с [Create Video](./create).
  </Step>

  <Step title="Опрос по id">
    Передайте сюда возвращённый `id` и продолжайте проверять, пока задание не перейдёт в состояние `completed` или `failed`.
  </Step>

  <Step title="Скачайте файл">
    Когда задание будет в состоянии `completed`, перейдите к [Retrieve Video Content](./retrieve-content).
  </Step>
</Steps>

## Форма ответа в CometAPI

Этот шаг точно соответствует workflow опроса Sora. CometAPI сохраняет форму объекта в стиле OpenAI, чтобы вы могли подключить проверки статуса с минимальной адаптацией.


## OpenAPI

````yaml api/openapi/video/sora-2/get-retrieve.openapi.json GET /v1/videos/{video_id}
openapi: 3.1.0
info:
  title: Retrieve Video API
  version: 1.0.0
  description: Retrieve the current status of a Sora video job created through CometAPI.
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/videos/{video_id}:
    get:
      summary: Retrieve a Sora video job
      description: >-
        Poll a previously created Sora video job until it is completed or
        failed.
      operationId: retrieve_video
      parameters:
        - name: video_id
          in: path
          required: true
          description: Video id returned by the create or remix endpoint.
          schema:
            type: string
      responses:
        '200':
          description: Current job state.
          content:
            application/json:
              schema:
                type: object
                required:
                  - id
                  - size
                  - model
                  - object
                  - status
                  - seconds
                  - progress
                  - created_at
                properties:
                  id:
                    type: string
                    description: Task id.
                  size:
                    type: string
                  error:
                    type:
                      - object
                      - 'null'
                  model:
                    type: string
                  object:
                    type: string
                  prompt:
                    type: string
                  status:
                    type: string
                    description: >-
                      Task state: `queued`, `in_progress`, `completed`, or
                      `failed`.
                  seconds:
                    type: string
                  progress:
                    type: integer
                    description: Render progress from 0 to 100.
                  created_at:
                    type: integer
                    description: Unix timestamp of task creation.
                  expires_at:
                    type:
                      - integer
                      - 'null'
                  completed_at:
                    type:
                      - integer
                      - 'null'
                    description: Unix timestamp of completion.
                  remixed_from_video_id:
                    type:
                      - string
                      - 'null'
                  video_url:
                    type: string
                    description: >-
                      Time-limited download URL present when `status` is
                      `completed`. Mirror the file to your own storage for long
                      retention.
                example:
                  id: video_69b25d5f467c81908733a56bc236b4df
                  size: 1280x720
                  error: null
                  model: sora-2
                  object: video
                  prompt: A paper airplane glides across a desk.
                  status: in_progress
                  seconds: '4'
                  progress: 0
                  created_at: 1773296991
                  expires_at: null
                  completed_at: null
                  remixed_from_video_id: null
              examples:
                In progress:
                  summary: Task still rendering
                  value:
                    id: <video_id>
                    model: sora-2
                    object: video
                    status: in_progress
                    progress: 30
                    created_at: 1781079478
                Completed:
                  summary: Finished task with video URL
                  value:
                    id: <video_id>
                    model: sora-2
                    object: video
                    status: completed
                    progress: 100
                    video_url: >-
                      https://comet-api-bucket.s3.us-east-1.amazonaws.com/videos/<video_id>.mp4?...
                    created_at: 1781079478
                    completed_at: 1781079550
      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.

````