视频生成
通过 Kling O1 全能视频接口,组合提示词、图片、Element、视频等输入生成视频。异步任务接口,提交后返回任务 ID,需轮询任务状态获取结果。
通过 Kling O1 全能视频接口,在同一请求中组合文本提示词、首尾帧、参考图、Element、特征参考视频与待编辑底视频。支持 720p / 1080p 分辨率,时长 3~10 秒。
异步任务型接口:提交后立即返回任务 id,需轮询任务状态,成功后再下载视频。
仅支持 Kling O1 模型。
Base URL
https://api.autorouter.top— Production
Authentication
BearerAuth: http (bearer)
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
Endpoints
POST /kling/omni-video/kling-o1
创建视频生成任务
通过 contents 参考输入集合(提示词、图片、Element、视频等)创建全能视频生成任务。
Headers
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Content-Type | string | Yes | application/json | 数据交换格式 |
Authorization | string | Yes | - | 鉴权信息,格式:Bearer sk-xxxxxx |
Request Body
Content-Type: application/json
Example:
{
"contents": [
{
"type": "prompt",
"text": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。"
},
{
"type": "first_frame",
"url": "https://example.com/first.png",
"id": "image_1"
},
{
"type": "refer_image",
"url": "https://example.com/refer.png",
"id": "image_2"
}
],
"settings": {
"resolution": "1080p",
"duration": 3,
"audio": "off"
},
"options": {
"callback_url": "https://xxx/callback",
"external_task_id": "",
"watermark_info": {
"enabled": false
}
}
}Properties:
| Name | Type | Required | Default | Enum | Description |
|---|---|---|---|---|---|
contents | array | Yes | - | - | 参考输入集合(提示词、图片、Element、视频等) |
contents[].type | string | Yes | - | prompt、first_frame、last_frame、refer_image、feature_video、base_video、element | 输入类型 |
settings | object | No | - | - | 输出配置,如分辨率、时长等 |
settings.audio | string | No | off | original、off | 是否为视频生成音频 |
settings.resolution | string | No | 720p | 720p、1080p | 生成视频的分辨率 |
settings.aspect_ratio | string | No | 16:9 | 16:9、9:16、1:1 | 生成视频画面的宽高比 |
settings.duration | int | No | 5 | 3~10 | 视频时长(秒) |
options | object | No | - | - | 通用配置,如回调地址、水印等 |
options.callback_url | string | No | - | - | 任务状态变化时的回调通知地址 |
options.external_task_id | string | No | - | - | 自定义任务 ID |
options.watermark_info | object | No | - | - | 是否同时生成带水印结果 |
contentsarray(必选)
参考输入集合,格式示例如下:
[
{
"type": "prompt",
"text": "string"
},
{
"type": "first_frame",
"url": "string",
"id": "string"
},
{
"type": "last_frame",
"url": "string",
"id": "string"
},
{
"type": "refer_image",
"url": "string",
"id": "string"
},
{
"type": "feature_video",
"url": "string",
"id": "string"
},
{
"type": "base_video",
"url": "string",
"id": "string"
},
{
"type": "element",
"element_id": "string",
"id": "string"
}
]输入类型:
prompt:文本提示词first_frame:首帧图片last_frame:尾帧图片refer_image:参考图(场景、风格等)feature_video:特征参考视频base_video:待编辑底视频element:Element(目前仅支持多图 Element;视频 Element 暂不支持)
{
"type": "prompt",
"text": "string"
}text:文本提示词,可包含正向与负向描述。最大长度 2500 字符- 可在提示词中通过
@xxx引用图片、Element 或视频,例如@image_1、@Zhang、@video_1 - 避免 Element 名称互为子串(如
@Zhang与@ZhangSan) - 避免 Element 名称与提示词正文重叠(例如提示词含邮箱时不要使用
@gmail) - 更多说明请参考 Kling O1 模型使用指南
{
"type": "first_frame",
"url": "string",
"id": "string"
}url:图片 URL 或 Base64(必填)id:输入索引 ID,用于在 prompt 中引用;同一任务内不可重复(可选)- 格式:
.jpg、.jpeg、.png - 大小: 不超过 50MB
- 尺寸: 宽高均不少于 300px;宽高比在
1:2.5~2.5:1
数量限制:
- 无参考视频 + 多图 Element:参考图 + 多图 Element ≤ 7
- 有参考视频 + 多图 Element:参考图 + 多图 Element ≤ 4
首尾帧规则:
- 仅支持「仅首帧」与「首帧 + 尾帧」;暂不支持「仅尾帧」
- 同时使用首帧与尾帧时,不可再添加其他参考图
{
"type": "feature_video",
"url": "string",
"id": "string"
}url:视频 URL(必填)id:输入索引 ID,用于在 prompt 中引用;同一任务内不可重复(可选)- 格式:
.mp4、.mov - 大小: 不超过 200MB
- 时长: 3~10 秒(含)
- 尺寸: 宽高均在 700px~2160px(含)
- 帧率: 24~60 fps(生成视频为 24 fps)
- 同一任务最多添加 1 个参考视频
feature_video:仅支持定义视频首帧,不支持尾帧base_video(待编辑视频):不支持定义首帧或尾帧
{
"type": "element",
"element_id": "string",
"id": "string"
}element_id:Element ID,由 Element 管理相关接口返回(必填)id:输入索引 ID,用于在 prompt 中引用;同一任务内不可重复(必填)- 目前仅支持多图 Element;视频 Element 暂不支持
- 使用首帧 + 尾帧时:不支持 Element
- 无参考视频:参考图 + Element ≤ 7
- 有参考视频:参考图 + Element ≤ 4
settingsobject(可选)
输出配置相关参数,如分辨率、时长等。
是否为视频生成音频。默认 off。
original:保留参考视频原声off:无音频
生成视频的分辨率。默认 720p。
720p:输出 720P 视频1080p:输出 1080P 视频
生成视频画面的宽高比。默认 16:9。
可选值:16:9、9:16、1:1
无首帧且无参考视频时,该参数必填。
视频时长(秒)。默认 5。
可选值:3、4、5、6、7、8、9、10
使用首帧生成视频,且无其他参考图(refer_image)或视频(feature_video / base_video)时,仅可生成 5 秒或 10 秒视频。
optionsobject(可选)
通用配置,如回调地址、是否含水印等。
{
"callback_url": "https://example.com/cb",
"external_task_id": "string",
"watermark_info": {
"enabled": false
}
}任务结果回调地址。配置后,任务状态变化时服务端会发送通知。
自定义任务 ID,不会覆盖系统生成的任务 ID,可用于查询。账号内必须唯一。
是否同时生成带水印结果。由 enabled 控制:
{
"enabled": false
}true:包含带水印结果false(默认):不含水印
暂不支持自定义水印。
Responses
200: 成功创建任务
Content-Type: application/json
请求示例
curl -X POST "https://api.autorouter.top/kling/omni-video/kling-o1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"contents": [
{
"type": "prompt",
"text": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。"
},
{
"type": "first_frame",
"url": "https://example.com/first.png",
"id": "image_1"
},
{
"type": "refer_image",
"url": "https://example.com/refer.png",
"id": "image_2"
}
],
"settings": {
"resolution": "1080p",
"duration": 3,
"audio": "off"
},
"options": {
"callback_url": "https://xxx/callback",
"watermark_info": {
"enabled": false
}
}
}'响应示例
{
"code": 0,
"message": "string",
"request_id": "string",
"data": {
"id": "string",
"status": "submitted",
"create_time": 1781080778802,
"update_time": 1781080794151,
"external_id": "string"
}
}响应字段说明:
| Name | Type | Description |
|---|---|---|
code | integer | 错误码,0 表示成功 |
message | string | 错误信息 |
request_id | string | 请求 ID,由系统生成 |
data.id | string | 系统生成的任务 ID |
data.status | string | 任务状态:submitted、processing、succeeded、failed |
data.create_time | integer | 任务创建时间,Unix 时间戳(毫秒) |
data.update_time | integer | 任务更新时间,Unix 时间戳(毫秒) |
data.external_id | string | 自定义任务 ID(如有) |
更多场景示例
首帧 & 参考图
curl -X POST "https://api.autorouter.top/kling/omni-video/kling-o1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"contents": [
{
"type": "prompt",
"text": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。"
},
{
"type": "first_frame",
"url": "https://example.com/first.png",
"id": "image_1"
},
{
"type": "refer_image",
"url": "https://example.com/refer.png",
"id": "image_2"
}
],
"settings": {
"resolution": "1080p",
"duration": 3,
"audio": "off"
}
}'首帧 & Element & 特征参考视频
curl -X POST "https://api.autorouter.top/kling/omni-video/kling-o1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"contents": [
{
"type": "prompt",
"text": "将鹦鹉羽毛颜色改为参考图中的颜色,保持视频其他元素不变。"
},
{
"type": "element",
"element_id": "161",
"id": "element_1"
},
{
"type": "first_frame",
"url": "https://example.com/first.png",
"id": "image_1"
},
{
"type": "feature_video",
"url": "https://example.com/feature.mp4",
"id": "video_1"
}
],
"settings": {
"resolution": "1080p",
"aspect_ratio": "16:9",
"audio": "off"
}
}'底视频 & 参考图
curl -X POST "https://api.autorouter.top/kling/omni-video/kling-o1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"contents": [
{
"type": "prompt",
"text": "将鹦鹉羽毛颜色改为参考图中的颜色,保持视频其他元素不变。"
},
{
"type": "refer_image",
"url": "https://example.com/refer.png",
"id": "image_1"
},
{
"type": "base_video",
"url": "https://example.com/base.mp4",
"id": "video_1"
}
],
"settings": {
"resolution": "1080p",
"aspect_ratio": "16:9",
"audio": "off"
}
}'GET /kling/tasks
查询视频生成任务
通过系统任务 ID 或自定义任务 ID 查询异步任务状态与结果。
task_ids与external_task_ids二选一,不可同时使用- 支持批量查询,多个 ID 以
,分隔 - 生成结果约 30 天后清理,请及时保存
Query Params
| Name | Type | Required | Description |
|---|---|---|---|
task_ids | string | No | 系统生成的任务 ID,多个以 , 分隔 |
external_task_ids | string | No | 自定义任务 ID,多个以 , 分隔 |
Responses
200: 成功查询任务
Content-Type: application/json
请求示例
curl -X GET "https://api.autorouter.top/kling/tasks?task_ids={id}" \
-H "Authorization: Bearer sk-xxxxxx"响应示例
以下为完整响应结构示意。
outputs中各type(video/image/audio/voice/element)字段不同;视频生成成功时通常仅返回type=video项。
{
"code": 0,
"message": "string",
"request_id": "string",
"data": [
{
"id": "893605946402811985",
"status": "succeeded",
"message": "string",
"create_time": 1781080778802,
"update_time": 1781080794151,
"external_id": "string",
"outputs": [
{
"type": "video",
"id": "string",
"url": "string",
"watermark_url": "string",
"duration": "string"
},
{
"type": "image",
"url": "string",
"watermark_url": "string",
"group_id": "string"
},
{
"type": "audio",
"id": "string",
"mp3_url": "string",
"wav_url": "string",
"mp3_duration": "string",
"wav_duration": "string"
},
{
"type": "voice",
"id": "string",
"name": "string",
"url": "string",
"owned_by": "string",
"status": "succeeded"
},
{
"type": "element",
"id": "string",
"name": "string",
"description": "string",
"element_type": "string",
"references": [
{
"type": "image",
"role": "string",
"url": "string"
},
{
"type": "video",
"role": "refer",
"url": "string"
},
{
"type": "voice",
"role": "refer",
"url": "string",
"id": "string",
"name": "string",
"owned_by": "string"
}
],
"owned_by": "string",
"status": "string",
"tags": [
{
"id": 1,
"name": "string",
"description": "string"
}
]
}
],
"billing": [
{
"charge_type": "string",
"cash_type": "string",
"amount": "string",
"package_type": "string",
"list_price": "string"
}
]
}
]
}响应字段说明:
| Name | Type | Description |
|---|---|---|
code | integer | 错误码,0 表示成功 |
message | string | 错误信息 |
request_id | string | 请求 ID,由系统生成,用于追踪与排查 |
data | object[] | 任务列表 |
data[].id | string | 被查询的任务 ID |
data[].status | string | 任务状态:submitted、processing、succeeded、failed |
data[].message | string | 任务状态信息;失败时展示失败原因(如触发内容风控) |
data[].create_time | integer | 任务创建时间,Unix 时间戳(毫秒) |
data[].update_time | integer | 任务更新时间,Unix 时间戳(毫秒) |
data[].external_id | string | 自定义任务 ID(如有) |
data[].outputs | object[] | 生成结果列表;字段随 type 变化,见下方说明 |
data[].outputs[].type | string | 结果类型:image、video、audio、element、voice |
data[].billing | object[] | 计费明细,见下方说明 |
data[].billing[].charge_type | string | 消耗账户类型:cash(余额)、unit(资源包) |
data[].billing[].cash_type | string | 余额类型,仅 charge_type=cash 时存在:balance、test_balance |
data[].billing[].amount | string | 扣费金额;余额场景为折扣价,资源包场景为扣减单位数 |
data[].billing[].package_type | string | 资源包类型,仅 charge_type=unit 时存在:video、image、audio |
data[].billing[].list_price | string | 余额扣费标价,仅 charge_type=cash 时存在 |
statusstring
任务状态:
submitted:已提交processing:处理中succeeded:成功failed:失败
建议轮询间隔 3~5 秒,直到 status 为 succeeded 或 failed。
outputsobject[]
生成结果列表。type 决定返回字段,可选值:image、video、audio、element、voice。视频生成成功时通常返回 type=video。
| Name | Type | Description |
|---|---|---|
type | string | 固定为 video |
id | string | 视频 ID,由系统生成 |
url | string | 生成结果 URL(防盗链格式;约 30 天后清理,请及时保存) |
watermark_url | string | 带水印结果 URL(防盗链格式) |
duration | string | 生成视频时长(秒) |
| Name | Type | Description |
|---|---|---|
type | string | 固定为 image |
url | string | 生成结果 URL(防盗链格式;约 30 天后清理) |
watermark_url | string | 带水印图片下载 URL(防盗链格式) |
group_id | string | 仅分组出图时出现,用于标记分组关系 |
| Name | Type | Description |
|---|---|---|
type | string | 固定为 audio |
id | string | 音频 ID,由系统生成 |
mp3_url | string | MP3 结果 URL(防盗链格式;约 30 天后清理) |
wav_url | string | WAV 结果 URL(防盗链格式;约 30 天后清理) |
mp3_duration | string | MP3 时长(秒) |
wav_duration | string | WAV 时长(秒) |
| Name | Type | Description |
|---|---|---|
type | string | 固定为 voice |
id | string | 音频 ID,由系统生成 |
name | string | 音频名称 |
url | string | 素材下载链接 |
owned_by | string | 音色来源:kling 为官方音色库,数字为创作者 ID |
status | string | 状态:succeeded、deleted |
| Name | Type | Description |
|---|---|---|
type | string | 固定为 element |
id | string | 元素 ID,由系统生成 |
name | string | 元素名称 |
description | string | 元素描述 |
element_type | string | 元素类型:video_character_elements、multi_image_elements |
references | object[] | 元素相关素材 |
references[].type | string | 素材类型:image、video、voice |
references[].role | string | 素材属性;图片为 frontal / reference,视频与音色为 refer |
references[].url | string | 素材下载链接 |
references[].id | string | 音色 ID(type=voice 时) |
references[].name | string | 音色名称(type=voice 时) |
references[].owned_by | string | 音色来源(type=voice 时) |
owned_by | string | 元素来源:kling 为官方库,数字为创作者 ID |
status | string | 状态:succeeded、deleted |
tags | object[] | 元素标签 |
tags[].id | integer | 标签 ID |
tags[].name | string | 标签名称 |
tags[].description | string | 标签描述 |
billingobject[]
计费明细。
消耗账户类型:
cash:余额扣费unit:资源包扣费
余额类型,仅 charge_type=cash 时存在:
balance:正式额度test_balance:测试额度
扣费金额。charge_type=cash 时为余额折扣价;charge_type=unit 时为资源包扣减单位数(十进制字符串)。
资源包类型,仅 charge_type=unit 时存在。固定枚举:video、image、audio。
余额扣费标价,仅 charge_type=cash 时存在。
错误处理
HTTP 400 参数错误
| 场景 | 处理建议 |
|---|---|
未传 contents | 补全必填字段 |
contents[].type 非法 | 使用文档列出的枚举值 |
| 首尾帧同时使用时额外传参考图 | 使用首尾帧时不要再传 refer_image |
无首帧且无参考视频时未传 aspect_ratio | 设置 settings.aspect_ratio |
duration / resolution 非法 | 使用文档列出的枚举值 |
HTTP 401 / 403 鉴权错误
401 Unauthorized:API Key 无效或已过期403 Forbidden:API Key 无权访问此模型
HTTP 402 余额不足
返回余额不足错误。请前往 AutoRouter 控制台充值。
任务 failed 状态
| 原因 | 处理建议 |
|---|---|
| 内容审核失败 | 调整提示词,避免敏感内容 |
| 参数组合非法 | 按 Request Body 规范传参 |
任务失败时 AutoRouter 会自动退款到你的账户。