Skip to content

Video Generation

POST /v1/videos/generations # submit job
GET /v1/videos/generations/{id} # poll status

Video generation is asynchronous. The submit call returns immediately with a job id and a poll_url; the client polls until status is completed (or failed).

FieldTypeDefaultDescription
modelstring"auto"Video model (see Providers). Use "auto" for health-aware routing.
promptstringrequiredText description. 1–8000 chars.
duration_secondsnumberprovider default1–60 seconds. Most models cap at 4–10s on free tier.
aspect_ratiostring"16:9"One of "16:9", "9:16", "1:1".
image_urlstringPublic HTTPS image URL for image-to-video models (Wan 2.6, Wan 2.2 I2V).
project_idstringBody-level project tag. Alternative to x-gateway-project-id header.
HeaderRequiredDescription
Authorization: Bearer <GATEWAY_API_KEY>yesGateway API key.
x-gateway-project-idyes (or body project_id)1–64 chars [a-zA-Z0-9._:-].

All video models currently route through Together AI (TOGETHER_API_KEY required).

Model IDUpstream ModelCapabilities
sora-2openai/sora-2Text-to-video
veo-3-audiogoogle/veo-3.0-audioText-to-video with audio
veo-3-fast-audiogoogle/veo-3.0-fast-audioFaster Veo 3 variant with audio
veo-2google/veo-2.0Text-to-video
kling-2.1-masterkwaivgI/kling-2.1-masterHigh-quality Kling
kling-2.1-prokwaivgI/kling-2.1-proKling pro tier
kling-2.0-masterkwaivgI/kling-2.0-masterPrevious-gen Kling
kling-1.6-prokwaivgI/kling-1.6-proKling 1.6
wan-2.6-imageWan-AI/Wan2.6-imageImage-to-video
wan-2.2-i2vWan-AI/Wan2.2-I2V-A14BImage-to-video
vidu-q1vidu/vidu-q1Text-to-video
seedream-3ByteDance-Seed/Seedream-3.0ByteDance Seedream
seedream-4ByteDance-Seed/Seedream-4.0ByteDance Seedream v4

Daily free-tier limits are tight (typically 10–30 requests per model per day). See GET /v1/models for the live enabled list.

Status 202 Accepted when the job is queued, or 200 OK if the provider happens to return a finished job synchronously.

{
"id": "job_abc123",
"status": "processing",
"poll_url": "/v1/videos/generations/job_abc123",
"x_gateway": {
"provider": "together",
"model": "openai/sora-2",
"attempts": 1,
"request_id": "req_xyz",
"project_id": "my_project"
}
}
{
"id": "job_abc123",
"status": "completed",
"video_url": "https://cdn.example/video.mp4",
"x_gateway": {
"provider": "together",
"model": "openai/sora-2",
"attempts": 1,
"request_id": "req_poll1",
"project_id": "my_project"
}
}

status is one of "processing", "completed", "failed". When failed, error contains the upstream message.

Terminal window
curl https://free-ai-gateway.sarthakagrawal927.workers.dev/v1/videos/generations \
-H "Authorization: Bearer <GATEWAY_API_KEY>" \
-H "x-gateway-project-id: my_project" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "A slow aerial drone shot over a misty mountain lake at dawn",
"duration_seconds": 5,
"aspect_ratio": "16:9"
}'
const BASE = 'https://free-ai-gateway.sarthakagrawal927.workers.dev';
async function pollUntilDone(jobId, { interval = 5000, timeout = 300_000 } = {}) {
const deadline = Date.now() + timeout;
while (Date.now() < deadline) {
const res = await fetch(`${BASE}/v1/videos/generations/${jobId}`, {
headers: { 'Authorization': 'Bearer <GATEWAY_API_KEY>' },
});
const body = await res.json();
if (body.status === 'completed') return body.video_url;
if (body.status === 'failed') throw new Error(body.error ?? 'job failed');
await new Promise((r) => setTimeout(r, interval));
}
throw new Error('poll timeout');
}
const videoUrl = await pollUntilDone('job_abc123');
console.log(videoUrl);
Terminal window
curl https://free-ai-gateway.sarthakagrawal927.workers.dev/v1/videos/generations \
-H "Authorization: Bearer <GATEWAY_API_KEY>" \
-H "x-gateway-project-id: my_project" \
-H "Content-Type: application/json" \
-d '{
"model": "wan-2.2-i2v",
"prompt": "Camera pans right as clouds roll in",
"image_url": "https://example.com/source-frame.jpg",
"duration_seconds": 4
}'
StatuscodeMeaning
400invalid_project_idMissing/invalid project_id.
404Job ID unknown, or upstream poll endpoint returned 404 (see beta caveat above).
502provider_errorSubmit or poll failed at upstream.
503no_video_providerTOGETHER_API_KEY not configured.