Overview
This guide covers the whole lifecycle of an API video: choosing resources, creating the project, following it until the video is ready, and downloading it.Step-by-step workflow
1. Authentication setup
.env
2. Choose a format
Each format has its own endpoint,POST /v1/project/create/{format}: talking avatar, UGC Studio, script to video, prompt to video, slideshow, scenes and more. You send your script (or prompt) and the ids the format needs, so each video can be completely different. Creating videos lists every endpoint.
The workflow
Step 1: Fetch resources
limit (up to 100) and offset and return a total; the music list returns every track. They change rarely, so cache them.
Step 2: Select resources
id as voiceId in create requests. A voice with unavailable: true is a cloned voice that only works in the key mode it was cloned in.
Which ones a format needs:
musicId is optional for most formats.
Step 3: Create the video
projectId right away. To resend a create that timed out, send it with the same Idempotency-Key; without one, check first.
Step 4: Monitor progress
Polling withGET /v1/project/{projectId}:
Use the project endpoint, not the video list: a project only appears in
GET /v1/video/list once its render has started, and one that fails before that never appears there.
Webhook: if you passed webhook, you get a POST with status: "COMPLETED" and data.url, or status: "FAILED". See Webhooks.
Step 5: Download
GET /v1/project/{projectId} again.
Personalized videos
To make one video per customer, build the script from your data and tag the project with your own id:GET /v1/project/{projectId} both return the metadata, so you always know which customer a video belongs to. See Personalization for writing scripts per recipient.
For many recipients, loop over your data with a small concurrency and your own ids in metadata. See Bulk Generation.
Re-rendering a project
If you edit a project in the dashboard editor after it was generated, render it again for free:GET /v1/video/{videoId}, or wait for the webhook. Re-rendering never costs credits. A project whose editor timeline is still empty answers 400.
Complete example
Best practices summary
Store the projectId
Store the projectId
It is the only handle you need:
GET /v1/project/{projectId} gives status, progress and the video.Webhook plus polling fallback
Webhook plus polling fallback
Webhooks are tried 3 times and then dropped. Poll any project you have not heard about after a while.
Retry creates with a key
Retry creates with a key
Retry GETs freely. Retry a create only with the same
Idempotency-Key; without one, check before re-sending.Keep your own copy
Keep your own copy
Download finished videos to your storage; links can expire.
Next steps
Bulk Generation
Generate at scale
Error Handling
React to every error