文生视频
通过文本提示词使用 Kling 3.0 生成视频。支持多镜头、原生音频、最高 4K、时长 3–15 秒。异步任务接口,提交后返回任务 ID,需轮询获取结果。
通过文本提示词生成视频,支持多镜头叙事、原生音频、720p / 1080p / 4k 分辨率,时长 3–15 秒。
异步任务型接口:提交后立即返回任务 id,需轮询任务状态,成功后再下载视频。
仅支持 Kling 3.0 模型。
Base URL
https://api.autorouter.top— Production
Authentication
BearerAuth: http (bearer)
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
Endpoints
POST /kling/text-to-video/kling-3.0
创建视频生成任务
通过文本提示词创建视频生成任务。
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:
{
"prompt": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。",
"settings": {
"resolution": "4k",
"aspect_ratio": "16:9",
"duration": 15,
"audio": "off",
"multi_shot": true
},
"options": {
"callback_url": "https://xxx/callback",
"external_task_id": "",
"watermark_info": {
"enabled": false
}
}
}Properties:
| Name | Type | Required | Default | Enum | Description |
|---|---|---|---|---|---|
prompt | string | Yes | - | - | 提示词,可包含正向与负向描述 |
settings | object | No | - | - | 输出配置,如分辨率、时长等 |
settings.multi_shot | boolean | No | true | - | 是否生成多镜头视频 |
settings.audio | string | No | off | native、off | 是否为视频生成音频 |
settings.resolution | string | No | 720p | 720p、1080p、4k | 生成视频的分辨率 |
settings.aspect_ratio | string | No | 16:9 | 16:9、9:16、1:1 | 生成视频画面的宽高比 |
settings.duration | int | No | 5 | 3–15 | 视频时长(秒) |
options | object | No | - | - | 通用配置,如回调地址、水印等 |
options.callback_url | string | No | - | - | 任务状态变化时的回调通知地址 |
options.external_task_id | string | No | - | - | 自定义任务 ID |
options.watermark_info | object | No | - | - | 是否同时生成带水印结果 |
promptstring(必选)
文本提示词,可包含正向与负向描述。最大长度 3072 字符(建议 ≤ 2500)。
示例值:一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。
多镜头格式: "shot n, m, words; shot n, m, words;"(以标准分号分隔),其中:
n:镜头序号(支持 1–6 个镜头)m:镜头时长(秒),每个镜头 ≥ 1s;所有镜头时长之和须等于视频总时长words:镜头提示词(最长 512 字符)
settingsobject(可选)
输出配置相关参数,如分辨率、时长等。
是否生成多镜头视频。默认 true。
设为 false 时,即使提示词使用多镜头格式,也不会输出多镜头视频。
是否为视频生成音频。默认 off。
native:生成与画面匹配的原生音频off:无音频
生成视频的分辨率。默认 720p。
720p:输出 720P 视频1080p:输出 1080P 视频4k:输出 4K 视频
生成视频画面的宽高比。默认 16:9。
可选值:16:9、9:16、1:1
视频时长(秒)。默认 5。
可选值:3、4、5、6、7、8、9、10、11、12、13、14、15
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/text-to-video/kling-3.0" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"prompt": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。",
"settings": {
"resolution": "4k",
"aspect_ratio": "16:9",
"duration": 15,
"audio": "off",
"multi_shot": true
},
"options": {
"callback_url": "https://xxx/callback",
"external_task_id": "",
"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(如有) |
GET /kling/tasks
查询视频生成任务(按任务 ID)
通过系统任务 ID 或自定义任务 ID 查询异步任务状态与结果。
当前接口仅支持查询异步任务。
task_ids与external_task_ids二选一,不可同时使用- 支持批量查询,多个 ID 以
,分隔 - 生成结果约 30 天后清理,请及时保存
Headers
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Content-Type | string | Yes | application/json | 数据交换格式 |
Authorization | string | Yes | - | 鉴权信息,格式:Bearer sk-xxxxxx |
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 "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx"响应示例
{
"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": "15"
}
],
"billing": [
{
"charge_type": "cash",
"cash_type": "balance",
"amount": "string",
"package_type": "video",
"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[].billing | object[] | 计费明细 |
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 参数错误
| 场景 | 处理建议 |
|---|---|
未传 prompt | 补全必填字段 |
duration / aspect_ratio / resolution 非法 | 使用文档列出的枚举值 |
| 多镜头时长之和不等于总时长 | 确保各镜头时长之和等于 settings.duration |
| 多镜头数量超过 6 | 最多使用 6 个镜头 |
HTTP 401 / 403 鉴权错误
401 Unauthorized:API Key 无效或已过期403 Forbidden:API Key 无权访问此模型
HTTP 402 余额不足
返回余额不足错误。请前往 AutoRouter 控制台充值。
任务 failed 状态
| 原因 | 处理建议 |
|---|---|
| 内容审核失败 | 调整提示词,避免敏感内容 |
| 参数组合非法 | 按 Request Body 规范传参 |
任务失败时 AutoRouter 会自动退款到你的账户。