Skip to content
Dashboard

Wan v2.7 Text-to-Video

Wan v2.7 Text-to-Video is the Wan 2.7 text-to-video model from Alibaba Cloud, generating clips of 2 to 15 seconds at 720p or 1080p with native audio and multi-shot narrative control through prompt language. Your use is subject to Alibaba Cloud's Terms & Privacy Policies.

text-to-video
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({
model: 'alibaba/wan-v2.7-t2v',
prompt: 'A serene mountain lake at sunrise.'
});
Read docs

Getting started

Generate videos with Wan v2.7 Text-to-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.

index.ts
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-v2.7-t2v',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
});
// 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

Drive the output with the top-level resolution and duration parameters. Wan uses resolution, not aspectRatio.

wan-text-to-video-top-level.ts
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-v2.7-t2v',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
resolution: '1280x720',
duration: 5,
});
// Save the generated video
fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');
}
main().catch(console.error);
ParameterTypeRequiredDescription
promptstringYesText description of the video to generate. Max 5000 characters.
durationnumberNoVideo length in seconds. 2-15 seconds.
resolutionstringNoResolution ('1280x720', '1920x1080').
aspectRatiostringNoAspect ratio ('16:9', '9:16', '1:1', '4:3', '3:4').
generateAudiobooleanNoGenerate synchronized audio with the video.

Input limits

InputFormatsSourcesMax countMax sizeLimits
TextUp to 5000 characters
Audiowav, mp3url15 MB2-30s

Provider options

Load the version-agnostic Wan options under providerOptions.alibaba. shotType (v2.6 only) and audioUrl (v2.5 only) are version-specific and documented in the table below.

wan-text-to-video-provider-options.ts
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-v2.7-t2v',
prompt: 'A chicken flying into the sunset in the style of 90s anime',
resolution: '1280x720',
duration: 5,
providerOptions: {
alibaba: {
promptExtend: true,
negativePrompt: 'blurry, low quality',
watermark: false,
pollIntervalMs: 5000,
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 Wan-specific options under providerOptions.alibaba in your generateVideo call.

ParameterTypeRequiredDescription
promptExtendbooleanNoEnhance prompt for better quality. Defaults to true.
negativePromptstringNoWhat to avoid in the video. Max 500 characters.
ratio'16:9' | '9:16' | '1:1' | '4:3' | '3:4'NoAspect ratio of the generated video. v2.7 text-to-video and reference-to-video only.
watermarkbooleanNoAdd watermark to the video. Defaults to false.
pollIntervalMsnumberNoHow often to check task status. Defaults to 5000.
pollTimeoutMsnumberNoMaximum wait time. Defaults to 600000 (10 minutes).