图生视频
POST /image-to-video/{model}:可灵 3.0 / 3.0 Turbo 图生视频,异步,用 GET /tasks 查询
POST/image-to-video/{model}
用首帧(可选尾帧、主体)和提示词生成视频。
| 项 | 值 |
|---|---|
| 模型 | kling-3.0-turbo / kling-3.0 |
| 模式 | 异步(提交 → 轮询 GET /tasks,见查询任务) |
| 计费 | 按输出视频时长(秒)结算 |
快速开始
curl https://api.vibelab.me/image-to-video/kling-3.0 \
-H "Authorization: Bearer $LOOPTOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"type": "prompt",
"text": "女孩坐在火车上望向窗外,神情忧郁"
},
{
"type": "first_frame",
"url": "https://example.com/start.jpg"
},
{
"type": "last_frame",
"url": "https://example.com/end.jpg"
}
],
"settings": {
"resolution": "1080p",
"duration": 10,
"audio": "native"
}
}'响应示例:
{
"code": 0,
"message": "SUCCEED",
"request_id": "6a0d571e-d36c-4811-bb2b-698c94b19a8c",
"data": {
"id": "893605946402811985",
"status": "submitted",
"create_time": 1781080778802,
"update_time": 1781080778802,
"external_id": "your-id"
}
}请求参数
请求头
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
Authorization | string | 是 | - | Bearer $LOOPTOKEN_API_KEY |
Content-Type | string | 是 | - | application/json |
路径参数
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
model | string | 是 | - | kling-3.0-turbo 或 kling-3.0 |
请求体
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
contents | array | 是 | - | 素材数组,元素见下 |
contents[].type=prompt | object | 否 | - | 提示词,字段 text,不超过 3072 个字符 |
contents[].type=first_frame | object | 是 | - | 首帧图,字段 url(公网 URL 或 Base64),必须有 |
contents[].type=last_frame | object | 否 | - | 尾帧图,字段 url;仅 kling-3.0,须与 first_frame 同时传 |
contents[].type=element | object | 否 | - | 主体引用,字段 element_id 和 id,最多 3 个;仅 kling-3.0 |
settings.resolution | string | 否 | 720p | 同文生视频 |
settings.duration | integer | 否 | 5 | 3–15 秒 |
settings.audio | string | 否 | off | 仅 kling-3.0:native 或 off |
options.callback_url | string | 否 | - | 任务状态变化时的 HTTPS 回调地址,见概览 |
options.external_task_id | string | 否 | - | 自定义任务 ID,同一账号下不可重复 |
options.watermark_info.enabled | boolean | 否 | false | 是否同时生成含水印结果 |
响应
| 字段 | 类型 | 说明 |
|---|---|---|
code | integer | 0 表示成功,其余见错误 |
message | string | 错误信息 |
request_id | string | 请求 ID,排查问题时提供 |
data.id | string | 任务 ID |
data.status | string | submitted、processing、succeeded、failed |
data.create_time、data.update_time | integer | Unix 毫秒时间戳 |
data.external_id | string | 创建时传入的 options.external_task_id,没传则无此字段 |
计费
按输出视频时长(秒)结算;任务失败全额退回。
错误
本页参数校验返回 400 / 1201,message 原文如下:
| HTTP | code | 触发场景 | 处理 |
|---|---|---|---|
| 404 | 1203 | model not found(路径 {model} 不是已上架的可灵模型) | 路径写 kling-3.0-turbo 或 kling-3.0 |
| 400 | 1201 | contents is required and must be a non-empty array | 传非空 contents 数组 |
| 400 | 1201 | contents must include a first_frame | 补一项 first_frame |
| 400 | 1201 | unsupported contents type "..." for ... | 只接受 prompt、first_frame、last_frame、element;kling-3.0-turbo 不接受 last_frame、element |
| 400 | 1201 | at most 3 elements are supported | element 不超过 3 个 |
| 400 | 1201 | prompt must not exceed 3072 characters | 缩短提示词 |
| 400 | 1201 | settings.resolution "..." is not supported for ... | 同文生视频 |
| 400 | 1201 | settings.duration must be between 3 and 15 | 传 3–15 的整数 |
| 400 | 1201 | settings.audio "..." is not supported for ... | kling-3.0 只接受 native/off;kling-3.0-turbo 不能传 |
通用错误(鉴权、余额、并发、回调地址、上游错误)见 Kling 错误。
注意事项
- 图片格式 → 支持 jpg、jpeg、png,宽高不小于 300px,宽高比在 1:2.5 到 2.5:1 之间。