Skip to main content
万相-早期视频模型(2.1-2.6)

万相-文生视频API参考(2.1-2.6)

万相-文生视频模型基于 文本提示词 ,生成一段流畅的视频。

相关文档使用指南

适用范围

为确保调用成功,请务必保证模型、Endpoint URL 和 API Key 均属于同一地域。跨地域调用将会失败。
本文的示例代码适用于新加坡地域
阿里云百炼为华北2(北京)、新加坡地域推出了业务空间专属域名,能够为推理请求提供卓越的性能和更高的稳定性,建议迁移至新域名:
  • 华北2(北京)地域:从 https://dashscope.aliyuncs.com 迁移至 https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com
  • 新加坡地域:从 https://dashscope-intl.aliyuncs.com 迁移至 https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
其中 {WorkspaceId} 为您的业务空间 ID,可在阿里云百炼控制台的业务空间详情页面查看。现有域名仍可正常使用。

HTTP调用

此接口为旧版协议,支持wan2.6及早期系列模型(wan2.5/wan2.2/wan2.1)
由于文生视频任务耗时较长(通常为1-5分钟),API采用异步调用。整个流程包含 “创建任务 -> 轮询获取” 两个核心步骤,具体如下:

步骤1:创建任务获取任务ID

  • 新加坡
  • 弗吉尼亚
  • 法兰克福
  • 北京
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis调用时请将{WorkspaceId}替换为真实的业务空间ID
  • 创建成功后,使用接口返回的 task_id 查询结果,task_id 有效期为 24 小时。请勿重复创建任务,轮询获取即可。
  • 新手指引请参见Postman

请求参数

请求头(Headers)
Content-Typestring(必选)请求内容类型。此参数必须设置为application/jsonAuthorizationstring(必选)请求身份认证。接口使用阿里云百炼API Key进行身份认证。示例值:Bearer sk-xxxx。X-DashScope-Asyncstring(必选)异步处理配置参数。HTTP请求只支持异步,必须设置为enable
缺少此请求头将报错:“current user api does not support synchronous calls”。
请求体(Request Body)
model string (必选)模型名称。可选模型请参见模型列表示例值:wan2.6-t2v。input object (必选)输入的基本信息,如提示词等。

属性

prompt string (必选)文本提示词。用来描述生成视频中期望包含的元素和视觉特点。支持中英文,每个汉字/字母占一个字符,超过部分会自动截断。长度限制因模型版本而异:
  • wan2.6和wan2.5系列模型:不超过1500个字符。
  • wan2.2 和wan2.1系列模型:不超过800个字符。
示例值:一只小猫在月光下奔跑。提示词的使用技巧请参见文生视频/图生视频Prompt指南negative_prompt string (可选)反向提示词,用来描述不希望在视频画面中看到的内容,可以对视频画面进行限制。支持中英文,长度不超过500个字符,超过部分会自动截断。示例值:低分辨率、错误、最差质量、低质量、残缺、多余的手指、比例不良等。audio_url string (可选)支持模型:wan2.6和wan2.5系列模型。音频文件URL,模型将使用该音频生成视频。支持输入的格式:
  1. 公网URL:
音频限制:
  • 格式:wav、mp3。
  • 时长:3~30s。
  • 文件大小:不超过15MB。
  • 超限处理:若音频长度超过 duration 值( 如5秒),自动截取前5秒,其余部分丢弃。若音频长度不足视频时长,超出音频长度部分为无声视频。例如,音频为3秒,视频时长为5秒,输出视频前3秒有声,后2秒无声。
parameters object (可选)图像处理参数。如设置视频分辨率、开启prompt智能改写、添加水印等。

属性

size string (可选)
  • size直接影响费用,请在调用前确认模型价格
  • size必须设置为具体数值(如 1280*720),而不是 1:1或480P。
指定生成的视频分辨率,格式为宽*高。该参数的默认值和可用枚举值依赖于 model 参数,规则如下:
  • wan2.6-t2v:默认值为 1920*1080(1080P)。可选分辨率:720P、1080P对应的所有分辨率。
  • wan2.6-t2v-us:默认值为 1920*1080(1080P)。可选分辨率:720P、1080P对应的所有分辨率。
  • wan2.5-t2v-preview:默认值为 1920*1080(1080P)。可选分辨率:480P、720P、1080P对应的所有分辨率。
  • wan2.2-t2v-plus:默认值为 1920*1080(1080P)。可选分辨率:480P、1080P对应的所有分辨率。
  • wan2.1-t2v-turbo :默认值为 1280*720(720P)。可选分辨率:480P、720P 对应的所有分辨率。
  • wan2.1-t2v-plus:默认值为1280*720(720P)。可选分辨率:720P 对应的所有分辨率。
480P档位:可选的视频分辨率及其对应的视频宽高比为:
  • 832*480:16:9。
  • 480*832:9:16。
  • 624*624:1:1。
720P档位:可选的视频分辨率及其对应的视频宽高比为:
  • 1280*720:16:9。
  • 720*1280:9:16。
  • 960*960:1:1。
  • 1088*832:4:3。
  • 832*1088:3:4。
1080P档位:可选的视频分辨率及其对应的视频宽高比为:
  • 1920*1080: 16:9。
  • 1080*1920: 9:16。
  • 1440*1440: 1:1。
  • 1632*1248: 4:3。
  • 1248*1632: 3:4。
duration integer (可选)
duration直接影响费用。费用 = 单价(基于分辨率)× 时长(秒),请在调用前确认模型价格
生成视频的时长,单位为秒。该参数的取值依赖于 model参数:
  • wan2.6-t2v:取值为[2, 15]之间的整数。默认值为5。
  • wan2.6-t2v-us:可选值为5、10。默认值为5。
  • wan2.5-t2v-preview:可选值为5、10。默认值为5。
  • wan2.2-t2v-plus:固定为5秒,且不支持修改。
  • wan2.1-t2v-plus:固定为5秒,且不支持修改。
  • wan2.1-t2v-turbo:固定为5秒,且不支持修改。
prompt_extendboolean (可选)是否开启prompt智能改写。开启后使用大模型对输入prompt进行智能改写。对于较短的prompt生成效果提升明显,但会增加耗时。
  • true:默认值,开启智能改写。
  • false:不开启智能改写。
shot_type string (可选)支持模型:wan2.6模型。指定生成视频的镜头类型,即视频是由一个连续镜头还是多个切换镜头组成。可选值:
  • single:默认值,输出单镜头视频。
  • multi:输出多镜头视频。
生效条件:仅当"prompt_extend": true 时生效。参数优先级:shot_type > prompt。例如,若 shot_type设置为"single",即使 prompt 中包含“生成多镜头视频”,模型仍会输出单镜头视频。watermark boolean (可选)是否添加水印标识,水印位于视频右下角,文案固定为“AI生成”。
  • false:默认值,不添加水印。
  • true:添加水印。
seedinteger(可选)随机数种子,取值范围为[0, 2147483647]未指定时,系统自动生成随机种子。若需提升生成结果的可复现性,建议固定seed值。请注意,由于模型生成具有概率性,即使使用相同 seed,也不能保证每次生成结果完全一致。
  • 多镜头叙事
  • 传入音频文件
  • 自动配音
  • 生成无声视频
  • 使用反向提示词
  • shot_type: 多镜头必须设为 "multi"
  • prompt_extend: 多镜头必须设为 true(开启智能改写以优化分镜描述)。

# 以下为新加坡地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。
curl --location 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis' \
    -H 'X-DashScope-Async: enable' \
    -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{
    "model": "wan2.6-t2v",
    "input": {
        "prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: \"The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them \"。",
        "audio_url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3"
    },
    "parameters": {
        "size": "1280*720",
        "prompt_extend": true,
        "duration": 10,
        "shot_type":"multi"
    }
}'

响应参数

output object任务输出信息。

属性

task_id string任务ID。查询有效期24小时。task_status string任务状态。

枚举值

  • PENDING:任务排队中
  • RUNNING:任务处理中
  • SUCCEEDED:任务执行成功
  • FAILED:任务执行失败
  • CANCELED:任务已取消
  • UNKNOWN:任务不存在或状态未知
request_idstring请求唯一标识。可用于请求明细溯源和问题排查。codestring请求失败的错误码。请求成功时不会返回此参数,详情请参见错误码messagestring请求失败的详细信息。请求成功时不会返回此参数,详情请参见错误码
  • 成功响应
  • 异常响应
请保存 task_id,用于查询任务状态与结果。
{
    "output": {
        "task_status": "PENDING",
        "task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
    },
    "request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}

步骤2:根据任务ID查询结果

  • 新加坡
  • 弗吉尼亚
  • 法兰克福
  • 北京
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}调用时请将{WorkspaceId}替换为真实的业务空间ID
  • 轮询建议:视频生成过程约需数分钟,建议采用轮询机制,并设置合理的查询间隔(如 15 秒)来获取结果。
  • 任务状态流转:PENDING(排队中)→ RUNNING(处理中)→ SUCCEEDED(成功)/ FAILED(失败)。
  • 结果链接:任务成功后返回视频链接,有效期为 24 小时。建议在获取链接后立即下载并转存至永久存储(如阿里云 OSS)。
  • task_id 有效期24小时,超时后将无法查询结果,接口将返回任务状态为UNKNOWN

请求参数

请求头(Headers)
Authorizationstring(必选)请求身份认证。接口使用阿里云百炼API Key进行身份认证。示例值:Bearer sk-xxxx。
URL路径参数(Path parameters)
task_id string(必选)任务ID。
  • 查询任务结果
{task_id}完整替换为上一步接口返回的task_id的值。task_id查询有效期为24小时,并请将{WorkspaceId}替换为真实的业务空间ID
curl -X GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id} \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

响应参数

outputobject任务输出信息。

属性

task_id string任务ID。查询有效期24小时。task_status string任务状态。

枚举值

  • PENDING:任务排队中
  • RUNNING:任务处理中
  • SUCCEEDED:任务执行成功
  • FAILED:任务执行失败
  • CANCELED:任务已取消
  • UNKNOWN:任务不存在或状态未知
轮询过程中的状态流转:
  • PENDING(排队中) → RUNNING(处理中)→ SUCCEEDED(成功)/ FAILED(失败)。
  • 初次查询状态通常为 PENDING(排队中)或 RUNNING(处理中)。
  • 当状态变为 SUCCEEDED 时,响应中将包含生成的视频URL。
  • 若状态为 FAILED,请检查错误信息并重试。
  • 若状态为 CANCELED,表示任务已取消,如需继续请重新提交任务。
  • 若状态为 UNKNOWN,表示任务不存在或状态未知,可能在 task_id 不存在或超过 24 小时有效期后出现。
submit_time string任务提交时间。时区为UTC+8,格式为 YYYY-MM-DD HH:mm:ss.SSS。scheduled_time string任务执行时间。时区为UTC+8,格式为 YYYY-MM-DD HH:mm:ss.SSS。end_time string任务完成时间。时区为UTC+8,格式为 YYYY-MM-DD HH:mm:ss.SSS。video_urlstring视频URL。仅在 task_status 为 SUCCEEDED 时返回。链接有效期24小时,可通过此URL下载视频。视频格式为MP4(H.264 编码)。orig_prompt string原始输入的prompt,对应请求参数promptactual_prompt stringprompt_extend=true 时,系统会对输入 prompt 进行智能改写,此字段返回实际用于生成的优化后 prompt。
  • prompt_extend=false,该字段不会返回。
  • 注意:wan2.6 模型无论 prompt_extend 取值如何,均不返回此字段。
codestring请求失败的错误码。请求成功时不会返回此参数,详情请参见错误码messagestring请求失败的详细信息。请求成功时不会返回此参数,详情请参见错误码
usage object输出信息统计。只对成功的结果计数。

属性

video_duration integer仅在使用 wan2.5 及以下版本模型时返回,用于计费。生成视频的时长,单位秒。枚举值为5、10。duration float仅在使用 wan2.6 模型时返回,用于计费。表示总的视频时长,且duration=input_video_duration+output_video_durationinput_video_duration integer仅在使用 wan2.6 模型时返回。固定为0。output_video_duration integer仅在使用 wan2.6 模型时返回。输出视频的时长,单位秒。其值等同于input.duration的值。SR integer仅在使用 wan2.6 模型时返回。生成视频的分辨率档位。示例值:720。size string仅在使用 wan2.6 模型时返回。生成视频的分辨率。格式为“宽,示例值:19201080。video_ratio string仅 wan2.5 及以下版本模型时返回。生成视频的分辨率。格式为“宽,示例值:832480。video_count integer生成视频的数量。固定为1。
request_idstring请求唯一标识。可用于请求明细溯源和问题排查。
  • 任务执行成功
  • 任务执行失败
  • 任务查询过期
视频URL仅保留24小时,超时后会被自动清除,请及时保存生成的视频。
{
    "request_id": "abbf7aa3-9652-4785-a622-xxxxxx",
    "output": {
        "task_id": "38513c71-5190-48e1-9f3b-xxxxxx",
        "task_status": "SUCCEEDED",
        "submit_time": "2025-09-29 14:05:22.119",
        "scheduled_time": "2025-09-29 14:05:28.278",
        "end_time": "2025-09-29 14:10:00.437",
        "orig_prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective's office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '。",
        "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx"
    },
    "usage": {
        "duration": 10,
        "size": "1280*720",
        "input_video_duration": 0,
        "output_video_duration": 10,
        "video_count": 1,
        "SR": 720
    }
}

DashScope SDK调用

SDK 的参数命名与HTTP接口基本一致,参数结构根据语言特性进行封装。 由于文生视频任务耗时较长(通常为1-5分钟),SDK 在底层封装了 HTTP 异步调用流程,支持同步、异步两种调用方式。
具体耗时受限于排队任务数和服务执行情况,请在获取结果时耐心等待。

Python SDK调用

请确保 DashScope Python SDK 版本不低于1.25.16,再运行以下代码。若版本过低,可能会触发 "url error, please check url!" 等错误。请参考安装SDK进行更新。
根据模型所在地域设置 dashscope.base_http_api_url:
  • 同步调用
  • 异步调用
请求示例
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os

# 以下为新加坡地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。获取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
# 各地域的API Key不同。获取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")

def sample_sync_call_t2v():
    # call sync api, will return the result
    print('please wait...')
    rsp = VideoSynthesis.call(api_key=api_key,
                              model='wan2.6-t2v',
                              prompt="Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.",
                              audio_url='https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3',
                              size='1280*720',
                              duration=10,
                              negative_prompt="",
                              prompt_extend=True,
                              watermark=False,
                              seed=12345)
    print(rsp)
    if rsp.status_code == HTTPStatus.OK:
        print(rsp.output.video_url)
    else:
        print('Failed, status_code: %s, code: %s, message: %s' %
              (rsp.status_code, rsp.code, rsp.message))

if __name__ == '__main__':
    sample_sync_call_t2v()
响应示例
video_url 有效期24小时,请及时下载视频。
{
    "status_code": 200,
    "request_id": "167f3beb-3dd0-47fe-a83c-xxxxxx",
    "code": null,
    "message": "",
    "output": {
        "task_id": "5b65411f-d946-4e29-859e-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-bj.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
        "submit_time": "2025-10-23 11:47:23.879",
        "scheduled_time": "2025-10-23 11:47:34.351",
        "end_time": "2025-10-23 11:52:35.323",
        "orig_prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective's office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '。"
    },
    "usage": {
        "video_count": 1,
        "video_duration": 0,
        "video_ratio": "",
        "duration": 10,
        "size": "1280*720",
        "input_video_duration": 0,
        "output_video_duration": 10,
        "SR": 720
    }
}

Java SDK调用

请确保 DashScope Java SDK 版本不低于2.22.14,再运行以下代码。若版本过低,可能会触发 "url error, please check url!" 等错误。请参考安装SDK进行更新。
根据模型所在地域设置 Constants.baseHttpApiUrl:
  • 新加坡
  • 弗吉尼亚
  • 北京
  • 法兰克福
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";调用时请将{WorkspaceId}替换为真实的业务空间ID
  • 同步调用
  • 异步调用
请求示例
// Copyright (c) Alibaba, Inc. and its affiliates.

// dashscope sdk >= 2.18.2
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

import java.util.HashMap;
import java.util.Map;

public class Text2Video {

    static {
          // 以下为新加坡地域的URL,调用时请将 {WorkspaceId} 替换为真实的业务空间ID,各地域的URL不同。获取URL:https://www.alibabacloud.com/help/en/model-studio/text-to-video-api-reference
         Constants.baseHttpApiUrl="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
    }

    // 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx"
    // 各地域的API Key不同。获取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
    public static String apiKey = System.getenv("DASHSCOPE_API_KEY");

    public static void text2Video() throws ApiException, NoApiKeyException, InputRequiredException {
        VideoSynthesis vs = new VideoSynthesis();
        Map<String, Object> parameters = new HashMap<>();
        parameters.put("prompt_extend", true);
        parameters.put("watermark", false);
        parameters.put("seed", 12345);

        VideoSynthesisParam param =
                VideoSynthesisParam.builder()
                        .apiKey(apiKey)
                        .model("wan2.6-t2v")
                        .prompt("Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '.")
                        .audioUrl("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250929/stjqnq/%E7%8B%90%E7%8B%B8.mp3")
                        .negativePrompt("")
                        .size("1280*720")
                        .duration(10)
                        .parameters(parameters)
                        .build();
        System.out.println("please wait...");
        VideoSynthesisResult result = vs.call(param);
        System.out.println(JsonUtils.toJson(result));
    }

    public static void main(String[] args) {
        try {
            text2Video();
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}
响应示例
video_url 有效期24小时,请及时下载视频。
{
    "request_id": "c1209113-8437-424f-a386-xxxxxx",
    "output": {
        "task_id": "966cebcd-dedc-4962-af88-xxxxxx",
        "task_status": "SUCCEEDED",
        "video_url": "https://dashscope-result-sh.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
        "orig_prompt": "Shot from a low angle, in a medium close-up, with warm tones, mixed lighting (the practical light from the desk lamp blends with the overcast light from the window), side lighting, and a central composition. In a classic detective office, wooden bookshelves are filled with old case files and ashtrays. A green desk lamp illuminates a case file spread out in the center of the desk. A fox, wearing a dark brown trench coat and a light gray fedora, sits in a leather chair, its fur crimson, its tail resting lightly on the edge, its fingers slowly turning yellowed pages. Outside, a steady drizzle falls beneath a blue sky, streaking the glass with meandering streaks. It slowly raises its head, its ears twitching slightly, its amber eyes gazing directly at the camera, its mouth clearly moving as it speaks in a smooth, cynical voice: 'The case was cold, colder than a fish in winter. But every chicken has its secrets, and I, for one, intended to find them '",
        "submit_time": "2026-01-22 23:13:40.553",
        "scheduled_time": "2026-01-22 23:13:49.415",
        "end_time": "2026-01-22 23:17:56.380"
    },
    "usage": {
        "video_count": 1,
        "duration": 10.0,
        "size": "1280*720",
        "input_video_duration": 0.0,
        "output_video_duration": 10.0,
        "SR": "720"
    },
    "status_code": 200,
    "code": "",
    "message": ""
}

错误码

如果模型调用失败并返回报错信息,请参见错误码进行解决。

常见问题

Q: 如何将临时的视频链接转为永久链接?

A: 不能直接转换该链接。正确的做法是:后端服务获取到url后,通过代码下载该视频文件,然后将其上传到永久对象存储服务(如阿里云 OSS),生成一个新的、永久访问链接。
import requests

def download_and_save_video(video_url, save_path):
    try:
        response = requests.get(video_url, stream=True, timeout=300) # 设置超时
        response.raise_for_status() # 如果HTTP状态码不是200,则引发异常
        with open(save_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                f.write(chunk)
        print(f"视频已成功下载到: {save_path}")
        # 此处可以接上传到永久存储的逻辑
    except requests.exceptions.RequestException as e:
        print(f"下载视频失败: {e}")

if __name__ == '__main__':
    video_url = "http://dashscope-result-sh.oss-cn-shanghai.aliyuncs.com/xxxx"
    save_path = "video.mp4"
    download_and_save_video(video_url, save_path)

Q: 返回的视频链接可以在浏览器中直接播放吗?

A: 不建议这样做,因为链接会在 24 小时后失效。最佳实践是后端下载转存后,使用永久链接进行视频播放。
文本生成
图像生成
音频
Realtime API
  • 概述
向量与排序
模型生产