Async Video Generation
Handle long-running video generation with async polling.
Video generation can take several minutes. Synchronous requests risk 502 timeouts from proxies, CDNs, or serverless function limits. Async mode solves this.
The Problem
When using a server proxy (Cloudflare, Vercel, etc.), requests that take longer than the proxy timeout (typically 30-60 seconds) will be killed with a 502 error. Video generation routinely exceeds this.
The Solution: Async Mode
Request Status Properties
| Property | Type | Description |
|---|---|---|
requestId | string | Unique request identifier |
status | string | "pending" | "processing" | "completed" | "failed" |
mediaType | string | "image" or "video" |
provider | string | Provider name |
model | string | Model identifier |
outputUrl | string | null | Output URL when completed |
errorMessage | string | null | Error message if failed |
createdAt | string | ISO timestamp of creation |
completedAt | string | null | ISO timestamp of completion |
Webhooks (Alternative)
Instead of polling, you can provide a webhook URL to get notified when the job completes:
The webhook will receive a POST request with the completed result and your callbackId.
Proxy Configuration
Make sure your server proxy route allows enough time: