Skip to main content

What you will build

You will submit a Sora 2 video job, store the returned video ID, poll until the job completes, and download the finished video content.

Prerequisites

  • A CometAPI API key stored in COMETAPI_KEY
  • Python 3.10+ with requests, or Node.js 18+
  • A server-side worker or job queue for polling

API key, base URL, authentication

Create Sora jobs with:
POST https://api.cometapi.com/v1/videos
Poll status with:
GET https://api.cometapi.com/v1/videos/<video_id>
Download completed content with:
GET https://api.cometapi.com/v1/videos/<video_id>/content
Authenticate with a Bearer token:
Authorization: Bearer $COMETAPI_KEY

Code examples

Use the tabs below for copyable examples in cURL, Python, and Node.js.
curl https://api.cometapi.com/v1/videos \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  -F model=sora-2 \
  -F "prompt=A paper boat drifts across a calm pond at sunrise" \
  -F seconds=4 \
  -F size=1280x720

curl "https://api.cometapi.com/v1/videos/<video_id>" \
  -H "Authorization: Bearer $COMETAPI_KEY"

curl "https://api.cometapi.com/v1/videos/<video_id>/content" \
  -H "Authorization: Bearer $COMETAPI_KEY" \
  --output sora-result.mp4

Flow explanation

Sora generation is asynchronous. The create endpoint returns a video ID and an initial status. Poll GET /v1/videos/<video_id> until status is completed or failed. When the job is complete, download the file with GET /v1/videos/<video_id>/content. Use exact WxH sizes. The Sora API reference documents standard landscape and portrait sizes, with larger Pro sizes for Pro model workflows.

Common parameters

ParameterUse
modelSora model ID. The reference example uses sora-2.
promptText prompt for the video.
secondsClip duration. The API reference documents 4, 8, 12, 16, and 20.
sizeExact WxH output size, such as 1280x720 or 720x1280.
input_referenceOptional reference image file for first-frame workflows.

Troubleshooting / FAQ

Use multipart form data. Sora create requests in the reference use form fields, not a JSON body.
Download content only after the status endpoint reports completed. Store the finished file in your own storage.
Use larger Pro sizes only with a Pro model workflow. Start with 1280x720 for a first request.

Next steps