Skip to content
Guides

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 storage

OpenAI-Compatible Video Endpoint (/v1/videos) ​

POSThttps://api.vanix.io/v1/videos
bash
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.mp4

Polling Best Practices ​

  1. Backoff interval: Poll every 5s for the first 30 seconds, then 10–15s until terminal state (completed / failed).
  2. Idempotent persistence: Save the returned task_id in your database immediately after POST so worker restarts resume polling instead of submitting duplicate paid jobs.
  3. Ephemeral asset URLs: Upstream signed video URLs expire quickly; copy completed media to your own S3/CDN bucket before serving end users.
  4. 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.

Vanix AI Unified Model Gateway · https://api.vanix.io