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_idWhat 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
resolutionandaspect_ratio, or an exactsize. - Duration control - set the length in whole seconds with
duration. - Shareable downloads - completed jobs return signed
urlsthat 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
- Submit with
POST /v1/videos. The API answers202 Acceptedwith a job whosestatusispending. - Poll the job's
polling_urlwithGET /v1/videos/:video_idevery 5-10 seconds untilstatusiscompleted,failed,cancelledorexpired. - Download a completed video from one of its
urls(no API key needed untilexpires_at) or itsunsigned_urls(needs your API key). Both point atGET /v1/videos/:video_id/content.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /v1/videos/models | List video models |
| POST | /v1/videos | Create video |
| GET | /v1/videos | List videos |
| GET | /v1/videos/:video_id | Retrieve video |
| GET | /v1/videos/:video_id/content | Retrieve content |
| DELETE | /v1/videos/:video_id | Delete 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.
| Field | Type | Description |
|---|---|---|
id | string | Unique job identifier. |
polling_url | string | Relative URL to poll: /v1/videos/{id}. |
status | string | One of pending, in_progress, completed, failed, cancelled, expired. |
error | string | Why the job failed. Only when status is failed or expired. |
unsigned_urls | string[] | Only when completed. Download URLs that need your API key. |
urls | string[] | Only when completed. Signed download URLs that work without an API key until expires_at. |
expires_at | integer | Unix timestamp after which urls stop working, about one hour after the response. Retrieve the job again for fresh URLs. |
usage | object | Only 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
| Status | Meaning |
|---|---|
pending | Accepted and waiting to start. |
in_progress | The model is rendering. |
completed | Finished; download it from urls or unsigned_urls. |
failed | The model rejected or could not render the job. You are not charged. |
expired | The job did not finish in time and was given up. You are not charged. |
cancelled | Reserved; 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.
| Status | error.type | Meaning |
|---|---|---|
400 | validation_error | The create body failed schema validation (for example a missing model, neither prompt nor frame_images, or a malformed duration or size). |
400 | invalid_request_error | Unknown model, an option or value the model does not support, or a size the model doesn't render. |
401 | authentication_error | Missing or invalid API key. |
402 | invalid_request_error | Create only: not enough credit for the job, an unpaid balance, or a spend limit was reached. |
403 | permission_denied_error | The 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. |
403 | invalid_request_error | The API key isn't scoped to a workspace (Videos API requires a workspace-scoped API key). |
404 | invalid_request_error | The video doesn't exist or belongs to another workspace, or (on create) the model is deprecated. |
409 | invalid_request_error | Video not yet completed (content endpoint). |
429 | rate_limit_error | Create only: your organization hit its rate limit for this model. Back off and retry. |
500 | internal_server_error | Unexpected failure on our side. Try again later. |
502 | internal_server_error | The video could not be fetched from the model yet. Try again later. |
502 / 503 | upstream_error | Create only: the model is temporarily unavailable. Safe to retry. |