跳转到主要内容
万相 2.6 及更早版本

Wan — 创建任务

提交文生视频任务(wan2.6 及更早版本)

POST
/services/aigc/video-generation/video-synthesis
import os
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope

dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'
api_key = os.getenv("DASHSCOPE_API_KEY", "YOUR_API_KEY")

print('please wait...')
rsp = VideoSynthesis.call(api_key=api_key,
                          model='wan2.6-t2v',
                          prompt='A thrilling detective chase story with cinematic storytelling. Shot 1 [0–3 s]: Wide shot of a rainy New York street at night, neon lights flickering, a detective in a black trench coat walking briskly. Shot 2 [3–6 s]: Medium shot of the detective entering an old building, rain soaking his coat, the door closing slowly behind him. Shot 3 [6–9 s]: Close-up of the detective\'s focused, determined eyes as distant sirens wail and he frowns slightly in thought. Shot 4 [9–12 s]: Medium shot of the detective moving carefully down a dim hallway, his flashlight illuminating the path ahead. Shot 5 [12–15 s]: Close-up of the detective discovering a key clue, his face lighting up with sudden realization.',
                          size="1280*720",
                          duration=15,
                          shot_type="multi",
                          prompt_extend=True,
                          watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
  print("video_url:", rsp.output.video_url)
else:
  print('Failed, status_code: %s, code: %s, message: %s' % (rsp.status_code, rsp.code, rsp.message))
{
  "request_id": "c1209113-8437-424f-a386-xxxxxx",
  "output": {
    "task_id": "966cebcd-dedc-4962-af88-xxxxxx",
    "task_status": "PENDING"
  }
}
Wan 文生视频模型支持文本、图片和音频输入,可生成最长 15 秒、最高 1080P 分辨率的视频。
  • 核心能力:支持整数时长(2–15 秒)、自定义分辨率(480P、720P、1080P)、提示词改写和水印。
  • 音频能力:支持自动配音或自定义音频文件,实现音视频同步。(wan2.5 和 wan2.6 支持)
  • 多镜头叙事:支持多镜头生成,转场时主体保持一致。(仅 wan2.6 支持)

鉴权

string
header
必填

千问云 API Key。详见获取 API Key

Header 参数

enum<string>
必填

异步任务提交时必须设置为 enable

enable

请求体

application/json
enum<string>
必填

模型名称。支持的模型及其能力详见端点描述中的模型列表。

wan2.6-t2v,wan2.5-t2v-preview,wan2.2-t2v-plus,wan2.1-t2v-turbo,wan2.1-t2v-plus
wan2.6-t2v
object
必填

视频生成的输入数据。

object

视频生成参数。

响应

200-application/json
string

请求的唯一标识符,用于追踪和排查问题。

c1209113-8437-424f-a386-xxxxxx
object