Skip to main content
A video template renders as an MP4. Each second of the video counts as one generation, and as two at 60 fps. Generate videos explains how to design one. render_video and render_and_wait_video take a template id and keyword arguments.
str
required
The id of a video template, for example tpl_xxx.
list[dict]
The values to put into the template’s layers. A video layer takes a src, and an audio track takes a src with its name. Modifications lists the fields each layer accepts.

Render and wait for the URL

render_and_wait_video returns {"result": url} or {"error": {...}}.

Follow the progress

render_video yields event dicts. The last event is done or error.
A refused request, such as an invalid API key or a used-up quota, gives one error event. The client timeout applies only to the connection, because a video can wait in line for minutes.

Reconnect after a dropped connection

The video renders to its end, even when the connection drops. Then render_video reads the same video again by the id from the created event, and it continues to yield events. It never sends the render again, so you do not pay for a second video. When the attempts run out, or the connection drops before the created event, the last event is an error with the code TIMEOUT_ERROR. render_and_wait_video reconnects in the same way.

Start a video without waiting

create_video starts the video and returns its id at once. It does not wait for the render. Then read the video with get_video or watch_video.
create_video sends the render only once. A second request renders a second video.

Read a video again

Keep the id from the created event. get_video returns the status of the video, and its URL when it is done.
status is queued, rendering, done, or failed. A failed video has an error string. An unknown id gives an error with the code NOT_FOUND. watch_video yields the events of the video again, from the latest one. It has no created event, and it reconnects as render_video does.