文生视频
通过文本提示词生成有声/无声视频。异步任务接口,提交后返回任务 ID,需轮询任务状态获取结果。
通过文本提示词生成视频,支持原生音频、720p / 1080p 分辨率,时长 5 或 10 秒。
异步任务型接口:提交后立即返回任务 id,需轮询任务状态,成功后再下载视频。
仅支持 Kling 2.6 模型。
Base URL
https://api.autorouter.top— Production
Authentication
BearerAuth: http (bearer)
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
Endpoints
POST /kling/text-to-video/kling-2.6
创建视频生成任务
通过文本提示词创建视频生成任务。
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": "1080p",
"aspect_ratio": "9:16",
"duration": 10
},
"options": {
"callback_url": "https://xxx/callback",
"external_task_id": "",
"watermark_info": {
"enabled": true
}
}
}Properties:
| Name | Type | Required | Default | Enum | Description |
|---|---|---|---|---|---|
prompt | string | Yes | - | - | 提示词,可包含正向与负向描述 |
settings | object | No | - | - | 输出配置,如分辨率、时长等 |
settings.audio | string | No | off | native、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 | 5、10 | 视频时长(秒) |
options | object | No | - | - | 通用配置,如回调地址、水印等 |
options.callback_url | string | No | - | - | 任务状态变化时的回调通知地址 |
options.external_task_id | string | No | - | - | 自定义任务 ID |
options.watermark_info | object | No | - | - | 是否同时生成带水印结果 |
promptstring(必选)
文本提示词,可包含正向与负向描述。最大长度 2500 字符。
示例值:一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。
settingsobject(可选)
输出配置相关参数,如分辨率、时长等。
是否为视频生成音频。默认 off。
native:生成与画面匹配的原生音频off:无音频
注意:开启原生音频时,仅支持 1080p 分辨率。
生成视频的分辨率。默认 720p。
720p:输出 720P 视频1080p:输出 1080P 视频
注意:开启原生音频时,仅支持 1080p。
生成视频画面的宽高比。默认 16:9。
可选值:16:9、9:16、1:1
视频时长(秒)。默认 5。
可选值: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/text-to-video/kling-2.6" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxx" \
-d '{
"prompt": "一个女孩坐在火车上,望着窗外,神情忧郁,头随着列车轻轻晃动。",
"settings": {
"resolution": "1080p",
"aspect_ratio": "9:16",
"duration": 10
},
"options": {
"callback_url": "https://xxx/callback",
"external_task_id": "",
"watermark_info": {
"enabled": true
}
}
}'响应示例
{
"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"响应示例
以下为完整响应结构示意。
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 参数错误
| 场景 | 处理建议 |
|---|---|
未传 prompt | 补全必填字段 |
| 原生音频 + 非 1080p | 将 settings.resolution 设为 1080p |
duration / aspect_ratio 非法 | 使用文档列出的枚举值 |
HTTP 401 / 403 鉴权错误
401 Unauthorized:API Key 无效或已过期403 Forbidden:API Key 无权访问此模型
HTTP 402 余额不足
返回余额不足错误。请前往 AutoRouter 控制台充值。
任务 failed 状态
| 原因 | 处理建议 |
|---|---|
| 内容审核失败 | 调整提示词,避免敏感内容 |
| 参数组合非法 | 按 Request Body 规范传参 |
任务失败时 AutoRouter 会自动退款到你的账户。