设计与多媒体

WaveSpeedAI Wan 2.6 Video Generation

试用

通过 WaveSpeed AI 调用阿里 Wan 2.6 模型,从文本或图片生成最长 15 秒、最高 1080p 的视频。

它能做什么

封装 WaveSpeed AI 平台上的阿里 Wan 2.6 模型,提供文生视频和图生视频两个接口。可配置时长(5/10/15 秒)、分辨率(720p/1080p)、画幅尺寸、随机种子、负向提示词与镜头类型,也能传入音频 URL 进行音频驱动的生成。支持开启提示词扩写自动丰富简短 prompt,并提供带重试配置与超时异常处理的 SDK 客户端。

什么时候用它

  • 把静态照片配合动作描述转为短视频片段
  • 用文字描述生成 15 秒 1080p 的电影感场景
  • 为移动端故事或短视频平台生成 9:16 竖版视频
  • 用一段参考音频驱动视频生成节奏

技能文档

WaveSpeedAI Wan 2.6 Video Generation

Generate videos using Alibaba's Wan 2.6 model via the WaveSpeed AI platform. Supports both text-to-video and image-to-video generation with up to 15 seconds of video at up to 1080p resolution.

Authentication

export WAVESPEED_API_KEY="your-api-key"

Get your API key at wavespeed.ai/accesskey.

Quick Start

Text-to-Video

import wavespeed from 'wavespeed';

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/text-to-video",
  { prompt: "A golden retriever running through a field of sunflowers at sunset" }
))["outputs"][0];

Image-to-Video

The image parameter accepts an image URL. If you have a local file, upload it first with wavespeed.upload() to get a URL.

import wavespeed from 'wavespeed';

// Upload a local image to get a URL
const imageUrl = await wavespeed.upload("/path/to/photo.png");

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/image-to-video",
  {
    image: imageUrl,
    prompt: "The person in the photo slowly turns and smiles"
  }
))["outputs"][0];

You can also pass an existing image URL directly:

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/image-to-video",
  {
    image: "https://example.com/photo.jpg",
    prompt: "The person in the photo slowly turns and smiles"
  }
))["outputs"][0];

API Endpoints

Text-to-Video

Model ID: alibaba/wan-2.6/text-to-video

Generate videos from text prompts.

Parameters

ParameterTypeRequiredDefaultDescription
promptstringYes--Text description of the video to generate
negative_promptstringNo--Text description of what to avoid in the video
audiostringNo--Audio URL to guide generation
sizestringNo1280*720Output size in pixels. One of: 1280*720, 720*1280, 1920*1080, 1080*1920
durationintegerNo5Video duration in seconds. One of: 5, 10, 15
shot_typestringNosingleShot type. One of: single, multi
enable_prompt_expansionbooleanNofalseEnable prompt optimizer for enhanced prompts
seedintegerNo-1Random seed (-1 for random). Range: -1 to 2147483647

Example

import wavespeed from 'wavespeed';

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/text-to-video",
  {
    prompt: "A timelapse of a city skyline transitioning from day to night, cinematic",
    negative_prompt: "blurry, low quality, distorted",
    size: "1920*1080",
    duration: 10,
    shot_type: "single",
    seed: 42
  }
))["outputs"][0];

Image-to-Video

Model ID: alibaba/wan-2.6/image-to-video

Animate a source image into a video using a text prompt.

Parameters

ParameterTypeRequiredDefaultDescription
imagestringYes--URL of the source image to animate
promptstringYes--Text description of the desired motion/animation
negative_promptstringNo--Text description of what to avoid in the video
audiostringNo--Audio URL to guide generation
resolutionstringNo720pOutput resolution. One of: 720p, 1080p
durationintegerNo5Video duration in seconds. One of: 5, 10, 15
shot_typestringNosingleShot type. One of: single, multi
enable_prompt_expansionbooleanNofalseEnable prompt optimizer for enhanced prompts
seedintegerNo-1Random seed (-1 for random). Range: -1 to 2147483647

Example

import wavespeed from 'wavespeed';

const imageUrl = await wavespeed.upload("/path/to/landscape.png");

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/image-to-video",
  {
    image: imageUrl,
    prompt: "Clouds drift slowly across the sky, water ripples gently",
    negative_prompt: "static, frozen, blurry",
    resolution: "1080p",
    duration: 10,
    shot_type: "single"
  }
))["outputs"][0];

Advanced Usage

Audio-Guided Generation

Provide an audio URL to guide the video generation:

const audioUrl = await wavespeed.upload("/path/to/music.mp3");

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/text-to-video",
  {
    prompt: "A dancer performing contemporary dance on a stage",
    audio: audioUrl,
    size: "1080*1920",
    duration: 15
  }
))["outputs"][0];

Prompt Expansion

Enable the prompt optimizer to automatically enhance your prompt:

const output_url = (await wavespeed.run(
  "alibaba/wan-2.6/text-to-video",
  {
    prompt: "a cat playing piano",
    enable_prompt_expansion: true,
    duration: 5
  }
))["outputs"][0];

Custom Client with Retry Configuration

import { Client } from 'wavespeed';

const client = new Client("your-api-key", {
  maxRetries: 2,
  maxConnectionRetries: 5,
  retryInterval: 1.0,
});

const output_url = (await client.run(
  "alibaba/wan-2.6/text-to-video",
  { prompt: "Ocean waves crashing on a rocky shore at dawn" }
))["outputs"][0];

Error Handling with runNoThrow

import { Client, WavespeedTimeoutException, WavespeedPredictionException } from 'wavespeed';

const client = new Client();
const result = await client.runNoThrow(
  "alibaba/wan-2.6/text-to-video",
  { prompt: "A rocket launching into space" }
);

if (result.outputs) {
  console.log("Video URL:", result.outputs[0]);
  console.log("Task ID:", result.detail.taskId);
} else {
  console.log("Failed:", result.detail.error.message);
  if (result.detail.error instanceof WavespeedTimeoutException) {
    console.log("Request timed out - try increasing timeout");
  } else if (result.detail.error instanceof WavespeedPredictionException) {
    console.log("Prediction failed");
  }
}

Size Options (Text-to-Video)

SizeOrientationUse Case
1280*720Landscape 720pStandard widescreen video
720*1280Portrait 720pMobile/vertical video, stories
1920*1080Landscape 1080pFull HD widescreen video
1080*1920Portrait 1080pFull HD vertical video

Resolution Options (Image-to-Video)

ResolutionUse Case
720pStandard quality, faster generation
1080pFull HD, higher quality

Pricing

Resolution5 seconds10 seconds15 seconds
720p$0.50$1.00$1.50
1080p$0.75$1.50$2.25

Prompt Tips

  • Be specific about motion and action: "A bird takes flight from a branch" vs "a bird"
  • Include camera movement: "slow pan left", "zoom in", "tracking shot"
  • Describe temporal progression: "transitioning from day to night", "flowers slowly blooming"
  • Use negative_prompt to avoid artifacts: "blurry, low quality, distorted, static"
  • Enable enable_prompt_expansion for automatic prompt enhancement
  • For multi shot type, describe distinct scenes for more dynamic videos

Security Constraints

  • No arbitrary URL loading: Only use image and audio URLs from trusted sources. Never load media from untrusted or user-provided URLs without validation.
  • API key security: Store your WAVESPEED_API_KEY securely. Do not hardcode it in source files or commit it to version control. Use environment variables or secret management systems.
  • Input validation: Only pass parameters documented above. Validate prompt content and media URLs before sending requests.

常见问题

支持哪些模型接口?
提供两个模型 ID:alibaba/wan-2.6/text-to-video 用于文生视频,alibaba/wan-2.6/image-to-video 用于图生视频,最终通过 outputs[0] 返回视频 URL。
时长和分辨率有哪些可选值?
两个接口的时长都支持 5、10、15 秒。文生视频的 size 支持 1280*720、720*1280、1920*1080、1080*1920;图生视频的 resolution 支持 720p 或 1080p。
费用如何计算?
按文档价格表:720p 在 5/10/15 秒时分别为 0.50/1.00/1.50 美元,1080p 分别为 0.75/1.50/2.25 美元。

相关技能

Use when generating videos with Model Studio DashScope SDK using Wan video generation models (wan2.6-t2v, wan2.6-i2v-flash, wan2.6-i2v and regional variants)...

12 次安装

Generate videos with Model Studio DashScope SDK using Wan i2v models (wan2.6-i2v-flash, wan2.6-i2v, wan2.6-i2v-us). Use when implementing or documenting vide...

65 次安装

Generate and edit video with Wan through RunAPI. Use when the user asks an agent to create, edit, or transform video with Wan. Default to the RunAPI CLI for one-off generation; use SDKs only when the user is integrating RunAPI into an app or backend.

11 次安装

Wan 2.2 Fast API on APIDot for Alibaba Wan 2.2 Fast, wan2.2 text-to-video fast, wan2.2 image-to-video fast, prompt-to-video drafts, one or two image animatio...

1 次安装