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

# Recuperar un video de Sora 2

> Usa CometAPI GET /v1/videos/{video_id} para recuperar el estado, el progreso y los metadatos de un video de Sora 2, como la duración, las dimensiones, las marcas de tiempo y la expiración.

Usa este endpoint después de iniciar un trabajo de Sora. Informa el estado actual del trabajo, el tamaño y la duración configurados, y cualquier error devuelto por el proveedor.

## Observa estos campos

* `status` para el estado del ciclo de vida
* `progress` para una señal aproximada del progreso
* `error` cuando el proveedor rechaza o falla el trabajo
* `expires_at` después de completarse si necesitas saber cuándo expiran los recursos temporales

## Haz polling hasta la finalización

<Steps>
  <Step title="Crea el video primero">
    Comienza con [Create Video](./create).
  </Step>

  <Step title="Haz polling por id">
    Pasa aquí el `id` devuelto y sigue comprobando hasta que el trabajo llegue a `completed` o `failed`.
  </Step>

  <Step title="Descarga el archivo">
    Cuando el trabajo esté `completed`, continúa con [Retrieve Video Content](./retrieve-content).
  </Step>
</Steps>

## Forma de la respuesta en CometAPI

Este paso coincide de cerca con el flujo de polling de Sora. CometAPI mantiene la forma de objeto al estilo OpenAI para que puedas conectar las comprobaciones de estado con una traducción mínima.


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

````