图生视频
根据单张图片生成视频,仅支持异步模式。调用该接口前,需要先调用“上传文件”接口获取图片的路径。
POST
https://cloud.baicaiinfer.com/v1/videos/generations
Authorizations
Body
application/json
task_type:EnumerateRequired
指定生成式模型需执行的任务类型,用于明确模型的工作目标,指定img2video。
input:object | nullRequired
输入参数集合。
input.image:StringRequired
原图资源。
input.prompt:StringRequired
是生成视频时用于描述期望内容(如场景、风格、细节等)的正向提示词。
input.negative_prompt:String
用于指定生成视频时需避免的元素(如低质量、失真等)的反向提示词,以优化生成结果的质量。
input.resolution:integerRequired
分辨率(1080P)。
input.aspect_ratio:integer
无需指定,以输入的原图的宽高比输出。
input.number_of_videos:integer
指定生成视频的数量,用于控制一次请求返回的视频总数,不传,则默认生成一个视频。
input.true_cfg_scale:numberRequired
指导尺度(通常 1.0 ~ 20.0,常用范围5.0 ~ 15.0):3.0 - 7.0表示获得更多意外惊喜和创意组合;7.0 - 10.0表示在遵循提示词和图像质量间取得平衡;10.0 - 15.0表示严格遵循文本描述,适合产品设计;1.0 - 5.0表示获得更抽象、interpretive的结果。
input.duration:integerRequired
视频时常(5s、10s)。
input.num_inference_steps:integerRequired
推理步数,影响单帧画面的生成质量和细节。
input.fps:integerRequired
每秒播放的帧数,影响视频播放的流畅度。
input.seed:integerRequired
生成式模型中控制结果随机性的种子,固定它可复现相同结果,改变则生成不同内容,示例:0。
need_expand_prompt:Boolean
优化提示词。
async:BooleanRequired
异步函数。
Response
状态码:application/json
200
code:String Required
表示请求处理状态的状态码。
0
400
500
0是成功标识,表示接口正常返回预期结果。
message:StringRequired
返回请求的处理结果,通常配合状态码使用,直观告知用户当前请求的具体情况。
data:objectRequired
任务的核心结果数据。
data.taskId:StringRequired
任务的唯一标识ID。
data.status:StringRequired
任务的执行状态,包括:PENDING、PROCESSING、COMPLETED、FAILED、CANCELED、UNKNOWN。
data.progress:StringRequired
任务完成进度,包括:排队中、生成中、已完成、已失败、用户主动取消、未知,对于taskId不存在时返回此状态,与status参数值一一对应。
result:objectRequired
任务返回的结果。
result.urls:String
是生成视频的网络访问链接,通过该URL可直接下载或在线查看视频文件,适合需要快速预览或通过链接分享的场景。
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": "JiMeng-I2V-V30-Pro",
"task_type": "img2video",
"input": {
"image": "https://s1.llamafactory.online/baicai-infer/users/04527f5b186a4b3587863399402cf0d2/KGD3Mz-Baicai_Creation_20260120150937498972.png",
"prompt": "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot.",
"negative_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards",
"resolution": 1080P,
"number_of_videos": 1,
"true_cfg_scale": 5,
"duration": 5s,
"num_inference_steps": 30,
"fps":16,
"seed": 0,
},
"need_expand_prompt": false,
"async": true
}'
200
400
401
404
500
{
"code": 0,
"message": "查询成功",
"data": [
{
"taskId": "f69895d0fcee4215b256c797d96*****",
"status": "COMPLETED",
"progress": "已完成",
"result": {
"urls": [
"https://s1.llamafactory.online/baicai-infer/results/f69895d0fcee4215b256c797d96*****/output_f69895d0fcee4215b256c797d965063c_0.mp4"
]
}
}
],
"ts": "2026-01-12T16:00:26.381364854+08:00[Asia/Shanghai]"
}