Video
Submit a video job, wait for completion, and download the generated clip.
Before You Begin
Configure your Router origin and key with the quickstart. You need an enabled video model, videos.write, available credits, and requests.read to inspect the job.
Video generation is asynchronous. Your application submits a prompt, retains the returned job ID, polls for completion, and downloads the content. Closing the client does not cancel the provider’s generation.
Submit a Job
Use an enabled model and its supported duration, resolution, and aspect ratio. The example uses the endpoint’s xAI profile; do not transfer those settings to a different provider without checking its contract.
curl --fail --show-error --request POST \
--url "$AUDIOLAB_API_URL/v1/videos/generations" \
--header "Authorization: Bearer $AUDIOLAB_API_KEY" \
--header 'Idempotency-Key: YOUR_UNIQUE_REQUEST_ID' \
--header 'Content-Type: application/json' \
--data '{
"model": "xai/grok-imagine-video",
"prompt": "VALUE",
"duration": 1
}'A 202 response means the job was accepted. Retain its AudioLab job ID and the Location header. It does not mean the video is ready. See Create Video for supported inputs and limits.
Wait for Completion
Poll Get Video Status using the originating API key. The status response includes current state, progress, settled cost, and an authenticated content path when available.
Use a bounded polling loop with a delay between requests. Handle a terminal failure separately from a pending or unresolved job. A status lookup never starts another generation.
Download and Retain the Clip
After completion, follow Download Video to retrieve the content with authentication. Save the asset promptly because content availability can expire. An expired output does not cause generation to restart.
Retain the original idempotency key for retries of the same request. Submitting a different key creates a separate logical request and can incur another charge. For interrupted or uncertain jobs, follow Errors and Debugging.