图生视频
根据单张图片生成视频,仅支持异步模式。调用该接口前,您需要先通过调用「上传文件」接口获取输入的原图路径;调用该接口后,您可通过调用「查询任务生成结果」接口获取视频的生成结果。
POST
https://cloud.baicaiinfer.com/v1/videos/generations
Authorizations
Body
application/json
input:ObjectRequired
输入参数集合。
input.image:StringRequired
原图资源(支持png、jpg格式)。
input.prompt:StringRequired
是生成视频时用于描述期望内容(如场景、风格、细节等)的正向提示词。
input.negative_prompt:String
用于指定生成视频时需避免的元素(如低质量、失真等)的反向提示词,以优化生成结果的质量。
input.resolution:StringRequired
分辨率(取值:480p、720p)。
input.aspect_ratio:String
无需指定,以输入的原图的宽高比输出。
input.duration:IntRequired
视频时常(取值:5),单位s。
input.number_of_videos:Int
指定生成视频的数量,取值范围为1~4。默认值:1。
input.num_inference_steps:Int
指定生成模型迭代优化的次数,次数越多生成视频细节越精细、质量越高,但同时会增加生成耗时,取值:1~50,默认值:28。
input.true_cfg_scale:Float
调节模型在生成时遵循文本提示词的程度,数值越大生成内容与提示词越一致,但可能降低多样性或导致过饱和,取值:0~20,默认值:9.0。
input.seed:Int
生成式模型中控制结果随机性的种子,固定它可复现相同结果,改变则生成不同内容,取值:-1~4294967295,默认值:-1。
need_expand_prompt:Boolean
优化提示词(取值:true、false),默认值:false。
async:Boolean
采用异步方式处理请求,默认值:true。
Response
状态码:application/json
200
code:IntRequired
表示请求处理状态的状态码。
0
400
500
0是成功标识,表示接口正常返回预期结果。
message:StringRequired
返回请求的处理结果,通常配合状态码使用,直观告知用户当前请求的具体情况。
data:objectRequired
任务的核心结果数据。
data.taskId:StringRequired
任务的唯一标识ID。
ts:StringRequired
响应的时间戳。
cURL
Python
JavaScript
curl --location --request POST 'https://cloud.baicaiinfer.com/v1/videos/generations' \
--header 'Authorization: Bearer sk-RVkVZVd57hLruMHEu9t*****' \
--header 'Content-Type: application/json' \
--data-raw '{
"selected_model": "Wan2.2-I2V-A14B-Fast",
"task_type": "img2video",
"input": {
"image": "https://s1.llamafactory.online/baicai-infer/users/04527f5b186a4b3587863399402cf0d2/KGD3Mz-Baicai_Creation_20260120150937498972.png",
"prompt": "图片中的人物踏云穿梭于七彩云海,动作流畅,光影绚丽。",
"resolution": "480p",
"duration": 5
}
}'
200
400
401
404
500
{
"code": 0,
"message": "任务提交成功",
"data": {
"taskId": "3524e0b3ba014b12ab1faf29f9f*****"
},
"ts": "2026-02-02T10:44:54.716004004+08:00[Asia/Shanghai]"
}