Videos

Generate videos from a text prompt or frame images with an async job API. Poll the job, then download the MP4.

The Videos API generates videos from a text prompt, optionally guided by a first and last frame image. Generation is asynchronous: you submit a job, poll it until it finishes, then download the MP4.

GET    /v1/videos/models
POST   /v1/videos
GET    /v1/videos
GET    /v1/videos/:video_id
GET    /v1/videos/:video_id/content
DELETE /v1/videos/:video_id

What you can do

  • Text-to-video - describe the scene in prompt.
  • Image-to-video - pin the first and/or last frame with frame_images.
  • Resolution and aspect ratio - pick resolution and aspect_ratio, or an exact size.
  • Duration control - set the length in whole seconds with duration.
  • Shareable downloads - completed jobs return signed urls that work without an API key until they expire.

The values each option accepts depend on the model. Find out what each model accepts (durations, resolutions, aspect ratios and per-second prices) with GET /v1/videos/models, or browse Models. A value the model does not list, or an option the model does not take at all, is rejected with 400; an option you leave out uses the model's own default.

Lifecycle

  1. Submit with POST /v1/videos. The API answers 202 Accepted with a job whose status is pending.
  2. Poll the job's polling_url with GET /v1/videos/:video_id every 5-10 seconds until status is completed, failed, cancelled or expired.
  3. Download a completed video from one of its urls (no API key needed until expires_at) or its unsigned_urls (needs your API key). Both point at GET /v1/videos/:video_id/content.

Endpoints

MethodEndpointDescription
GET/v1/videos/modelsList video models
POST/v1/videosCreate video
GET/v1/videosList videos
GET/v1/videos/:video_idRetrieve video
GET/v1/videos/:video_id/contentRetrieve content
DELETE/v1/videos/:video_idDelete video

Every endpoint expects a bearer token in the Authorization header, except a content download through a signed URL. Create keys at Manage API Keys.

The video job object

Returned by create, retrieve and list. Fields that do not apply to the job's current status are omitted rather than set to null.

FieldTypeDescription
idstringUnique job identifier.
polling_urlstringRelative URL to poll: /v1/videos/{id}.
statusstringOne of pending, in_progress, completed, failed, cancelled, expired.
errorstringWhy the job failed. Only when status is failed or expired.
unsigned_urlsstring[]Only when completed. Download URLs that need your API key.
urlsstring[]Only when completed. Signed download URLs that work without an API key until expires_at.
expires_atintegerUnix timestamp after which urls stop working, about one hour after the response. Retrieve the job again for fresh URLs.
usageobjectOnly when the job has finished. { cost, is_byok }: cost is the charge in USD (0 for a failed job, null while it is still being recorded); is_byok is always false.

Statuses

StatusMeaning
pendingAccepted and waiting to start.
in_progressThe model is rendering.
completedFinished; download it from urls or unsigned_urls.
failedThe model rejected or could not render the job. You are not charged.
expiredThe job did not finish in time and was given up. You are not charged.
cancelledReserved; not produced today.

Errors

All errors share one shape:

{ "error": { "message": "...", "type": "invalid_request_error" } }

Errors raised by the Videos API itself use type invalid_request_error for every 4xx, so branch on the HTTP status code.

Statuserror.typeMeaning
400validation_errorThe create body failed schema validation (for example a missing model, neither prompt nor frame_images, or a malformed duration or size).
400invalid_request_errorUnknown model, an option or value the model does not support, or a size the model doesn't render.
401authentication_errorMissing or invalid API key.
402invalid_request_errorCreate only: not enough credit for the job, an unpaid balance, or a spend limit was reached.
403permission_denied_errorThe account is suspended, an Admin key was used, the model isn't included in your organization's tier, or a signed content URL has an invalid or expired signature.
403invalid_request_errorThe API key isn't scoped to a workspace (Videos API requires a workspace-scoped API key).
404invalid_request_errorThe video doesn't exist or belongs to another workspace, or (on create) the model is deprecated.
409invalid_request_errorVideo not yet completed (content endpoint).
429rate_limit_errorCreate only: your organization hit its rate limit for this model. Back off and retry.
500internal_server_errorUnexpected failure on our side. Try again later.
502internal_server_errorThe video could not be fetched from the model yet. Try again later.
502 / 503upstream_errorCreate only: the model is temporarily unavailable. Safe to retry.