Wan v3.0 Video
All-in-one video generation model supporting text-to-video, image-to-video, first/last-frame, and omni-modal reference-based generation (image, video, and audio references) with synchronized audio, at up to 30 seconds per clip. Your use is subject to Alibaba Cloud's Terms & Privacy Policies.
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({ model: 'alibaba/wan-v3.0-video', prompt: 'A serene mountain lake at sunrise.'});Getting started
Generate videos with Wan v3.0 Video using the experimental_generateVideo function from AI SDK 6 or later. AI Gateway handles routing and polls until the video is ready.
Install the AI SDK (pnpm add ai dotenv), create an API key from the API Keys page, and set it as AI_GATEWAY_API_KEY in your environment. Full setup is covered in the video generation quickstart.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'alibaba/wan-v3.0-video', prompt: 'A drone shot of a coastal cliff with crashing waves at golden hour.', });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);Top-level parameters
Load the common, top-level parameters supported across video models.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'alibaba/wan-v3.0-video', prompt: 'A drone shot of a coastal cliff with crashing waves at golden hour.', duration: 5, aspectRatio: '16:9', resolution: '1280x720', });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | No | Text description of the video to generate. Max 20000 characters. |
duration | number | No | Video length in seconds. 2-30 seconds. |
resolution | string | No | Resolution ('854x480', '1280x720', '1920x1080'). |
aspectRatio | string | No | Aspect ratio ('16:9', '4:3', '1:1', '3:4', '9:16'). |
Input limits
| Input | Formats | Sources | Max count | Max size | Limits |
|---|---|---|---|---|---|
| Text | — | — | — | — | Up to 20000 characters |
| Image | jpeg, jpg, png, bmp, webp | url, base64 | 10 | 20 MB | ≥240px · ≤8000px · aspect 1:8–8:1 |
| Video | mp4, mov | url | 5 | 100 MB | 1-15s · ≥240px · ≤4096px |
| Audio | wav, mp3 | url | — | 15 MB | 1-15s |
Provider options
Pass provider-specific options under providerOptions.alibaba.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'alibaba/wan-v3.0-video', prompt: 'A drone shot of a coastal cliff with crashing waves at golden hour.', duration: 5, providerOptions: { alibaba: { pollTimeoutMs: 600000, }, }, });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);Pass these under providerOptions.alibaba in your generateVideo call.
| Parameter | Type | Required | Description |
|---|---|---|---|
providerOptions.alibaba.pollIntervalMs | number | No | How often to check task status. Defaults to 5000. |
providerOptions.alibaba.pollTimeoutMs | number | No | Maximum wait time. Defaults to 600000 (10 minutes). |