Video & Async Tasks
Video generation models run asynchronously for 30 seconds to several minutes. Vanix AI provides a unified submit-and-poll lifecycle with automatic task tracking and atomic billing settlement (failed jobs are refunded automatically).
Standard Async Lifecycle
text
1. POST submit endpoint ──► 200 OK { "id": "task_...", "status": "queued" }
2. Poll GET status (5–15s) ──► "queued" → "in_progress" → "completed" | "failed"
3. Fetch / Download asset ──► Persist MP4 immediately to your own object storageOpenAI-Compatible Video Endpoint (/v1/videos)
POST
https://api.vanix.io/v1/videosbash
curl https://api.vanix.io/v1/videos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VANIX_API_KEY" \
-d '{
"model": "sora-2",
"prompt": "Slow aerial dolly shot over Tokyo Shibuya crossing at twilight, cinematic anamorphic lens",
"seconds": "8",
"size": "1280x720"
}'bash
curl https://api.vanix.io/v1/videos/VIDEO_TASK_ID \
-H "Authorization: Bearer $VANIX_API_KEY"bash
curl -L https://api.vanix.io/v1/videos/VIDEO_TASK_ID/content \
-H "Authorization: Bearer $VANIX_API_KEY" \
-o output.mp4Polling Best Practices
- Backoff interval: Poll every
5sfor the first 30 seconds, then10–15suntil terminal state (completed/failed). - Idempotent persistence: Save the returned
task_idin your database immediately afterPOSTso worker restarts resume polling instead of submitting duplicate paid jobs. - Ephemeral asset URLs: Upstream signed video URLs expire quickly; copy completed media to your own S3/CDN bucket before serving end users.
- Automatic refund on failure: If an upstream provider rejects or fails a generation task, Vanix AI settles the task as failed and restores the pre-consumed quota.