Skip to Content
接口文档视频生成接口

视频生成接口(Video Generation)

POST https://ai.amaxsmp.com/v1/video/generations

根据文本描述生成视频,也可以传入图片或参考视频。接口先返回任务 ID,生成完成后通过视频任务查询获取结果。

支持模型

平台已接入 Seedance、Sora、Veo、可灵、即梦、通义万相、Vidu、海螺等视频模型。可用模型及其支持的输入方式、时长、分辨率,以控制台当前配置为准。

以下示例使用 doubao-seedance-2-0-fast-260128。调用前请确认你的 API Key 可使用该模型,且模型支持示例中的 5 秒和 720P

请求示例

cURL

curl https://ai.amaxsmp.com/v1/video/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -d '{ "model": "doubao-seedance-2-0-fast-260128", "prompt": "镜头缓缓掠过清晨的湖面,远处山峰倒映在水中", "duration": 5, "resolution": "720P" }'

Python(requests)

安装依赖:pip install requests

import requests response = requests.post( "https://ai.amaxsmp.com/v1/video/generations", headers={"Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}, json={ "model": "doubao-seedance-2-0-fast-260128", "prompt": "镜头缓缓掠过清晨的湖面,远处山峰倒映在水中", "duration": 5, "resolution": "720P", }, timeout=120, ) response.raise_for_status() payload = response.json() task = payload.get("data") or payload task_id = task.get("task_id") or task.get("id") if not task_id: raise RuntimeError(payload) print(task_id)

JavaScript(Node.js 18+)

const response = await fetch("https://ai.amaxsmp.com/v1/video/generations", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", }, body: JSON.stringify({ model: "doubao-seedance-2-0-fast-260128", prompt: "镜头缓缓掠过清晨的湖面,远处山峰倒映在水中", duration: 5, resolution: "720P", }), }); const payload = await response.json(); if (!response.ok) throw new Error(JSON.stringify(payload)); const task = payload.data ?? payload; const taskId = task.task_id ?? task.id; if (!taskId) throw new Error(JSON.stringify(payload)); console.log(taskId);

图生视频

向同一接口提交以下 JSON,将 image 替换为可访问的图片 URL。仅适用于支持图片输入的模型,部分模型将图片用作首帧。

{ "model": "doubao-seedance-2-0-fast-260128", "prompt": "保持画面主体不变,让镜头缓缓向前推进", "duration": 5, "resolution": "720P", "image": "https://example.com/first-frame.png" }

参考视频生成

先通过参考视频上传获取 data.url,再将该地址作为 video 提交。仅适用于支持视频输入的模型。

{ "model": "doubao-seedance-2-0-fast-260128", "prompt": "参考原视频的镜头运动,将场景改为雪后的森林", "duration": 5, "resolution": "720P", "video": "https://example.com/reference.mp4" }

请求参数

参数类型必填说明
modelstring当前 API Key 可用的视频模型名
promptstring视频内容和动作描述
durationint是,与 seconds 二选一生成时长,单位为秒,必须符合模型支持范围
resolutionstring是,与 size 二选一分辨率,如 720P1080P,必须符合模型支持范围
imagestring单张图片 URL 或 Base64 数据,具体格式由模型决定
imagesstring[]多张图片;数量、顺序和用途由模型决定
videostring单个参考视频 URL
videosstring[]多个参考视频 URL,需模型支持
video_urlstring单个参考视频 URL 的兼容字段
secondsstringduration 的兼容字段,如 "5"
sizestringresolution 的兼容字段,如 1280x720
metadataobject模型专用参数,支持项由对应模型决定

推荐使用 durationresolution。若同时传入兼容字段,时长和分辨率必须一致,否则返回参数错误。图片和视频输入优先各使用一种字段,避免重复传入同一素材。

响应示例

以下为 Seedance 提交成功后的响应示例,返回任务并不代表视频已生成完成。

{ "id": "task_example", "task_id": "task_example", "object": "video", "model": "doubao-seedance-2-0-fast-260128", "status": "queued", "progress": 0, "created_at": 1788832800 }

不同模型的响应包装可能不同。保存响应中的 task_id;如果响应包含 data 对象,则读取 data.task_id,也可兼容 id 字段。随后调用视频任务查询,不要为查询进度重复提交生成请求。

常见错误

错误码说明
video_capability_not_configured模型尚未配置视频时长或分辨率,请更换模型或联系支持
invalid_video_parameters缺少时长、分辨率,或兼容字段发生冲突
unsupported_video_duration时长不在所选模型的支持范围内
unsupported_video_resolution分辨率不在所选模型的支持范围内

鉴权、额度和资产空间错误请结合 HTTP 状态码及响应中的 messageerror.message 处理。

计费

视频生成按时长计费,价格可能随模型、分辨率及是否包含参考视频变化。具体价格请登录控制台查看。