Kling O1
Kling O1 视频生成接口,支持通过文本、图片和视频素材生成或编辑视频。
Kling O1 通过异步任务接口处理文本、图片、主体和视频素材。提交任务后先获得任务 ID,再查询任务状态和生成结果。
创建任务
| 项目 | 值 |
|---|---|
| 请求方法 | POST |
| 请求地址 | https://token.aiznt.com/omni-video/kling-o1 |
| 认证方式 | Header Authorization: Bearer sk-你的密钥 |
| Content-Type | application/json |
curl https://token.aiznt.com/omni-video/kling-o1 \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"type": "prompt",
"text": "让人物在城市街道中自然行走,镜头平稳跟随"
},
{
"type": "first_frame",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-tob-release_note/image_25.png",
"id": "image_1"
},
{
"type": "refer_image",
"url": "https://p2-kling.klingai.com/kcdn/cdn-kcdn112452/kling-tob-release_note/image_25.png",
"id": "image_2"
}
],
"settings": {
"resolution": "1080p",
"duration": 5,
"aspect_ratio": "16:9",
"audio": "off"
},
"options": {
"external_task_id": "video-task-o1",
"watermark_info": {
"enabled": false
}
}
}'请求参数
| 字段 | 类型 | 必填 | 默认值 | 可选值 | 说明 |
|---|---|---|---|---|---|
contents | array | 是 | - | - | 参考素材合集,可组合提示词、图片、主体和视频。 |
contents[].type | string | 是 | - | prompt、first_frame、last_frame、refer_image、feature_video、base_video、element | 素材类型。 |
contents[].text | string | prompt 时必填 | - | - | 文本提示词,最多 2500 个字符,可包含正向和负向描述。 |
contents[].url | string | 图片/视频类型必填 | - | URL(图片也支持 Base64) | 图片或视频素材内容。 |
contents[].id | string | 否(element 时必填) | - | - | 素材索引 ID,在提示词中用 @id 引用;同一任务内不能重复。 |
contents[].element_id | string | element 时必填 | - | - | 系统生成的主体 ID。 |
settings | object | 否 | - | - | 输出设置。 |
settings.audio | string | 否 | off | original、off | original 保留参考视频原声;off 不生成声音。 |
settings.resolution | string | 否 | 720p | 720p、1080p | 生成视频清晰度。 |
settings.aspect_ratio | string | 条件必填 | 16:9 | 16:9、9:16、1:1 | 没有首帧图且没有参考视频时必须显式传入。 |
settings.duration | integer | 否 | 5 | 3~10 | 视频时长(秒)。仅首帧且没有其他参考图或视频时,只支持 5 秒或 10 秒。 |
options | object | 否 | - | - | 回调、自定义任务 ID 和水印设置。 |
options.callback_url | string | 否 | - | - | 任务状态变化时接收回调通知的地址。 |
options.external_task_id | string | 否 | - | - | 自定义任务 ID;同一账户内应保持唯一,可用于查询。 |
options.watermark_info | object | 否 | - | - | 水印配置对象。 |
options.watermark_info.enabled | boolean | 否 | false | true、false | 是否同时生成带水印结果;暂不支持自定义水印。 |
contents 素材类型
type | 用途 | 需要的字段 |
|---|---|---|
prompt | 提示词素材 | text |
first_frame | 视频首帧图片 | url;id 可选 |
last_frame | 视频尾帧图片 | url;id 可选 |
refer_image | 场景、风格或元素参考图 | url;id 可选 |
feature_video | 特征参考视频 | url;id 可选 |
base_video | 待编辑视频 | url;id 可选 |
element | 已创建的主体素材 | element_id、id |
素材与组合规则
- 图片支持 JPG、JPEG、PNG;大小不超过 50 MB,宽高均不小于 300 px,宽高比为
1:2.5~2.5:1。 - 视频支持 MP4、MOV;大小不超过 200 MB,时长 3~10 秒,宽高 700~2160 px,帧率 24~60 fps;最多添加 1 段参考视频。
first_frame、last_frame、refer_image使用图片;支持仅首帧或首帧+尾帧,不支持仅尾帧。首尾帧同时使用时不能再添加其他参考图。feature_video仅支持定义视频首帧;base_video不支持定义视频首帧或尾帧。element仅支持多图主体,不支持视频角色主体。使用首尾帧时不能添加主体。- 无参考视频时,参考图片与主体数量之和不超过 7;有参考视频时不超过 4。
- 可在提示词中使用
@id引用图片、主体或视频;素材 ID 必须唯一,并避免 ID 互相包含或与提示词文本产生歧义。
创建响应
{
"code": 0,
"message": "string",
"request_id": "string",
"data": {
"id": "893605946402811985",
"status": "submitted",
"create_time": 1781080778802,
"update_time": 1781080794151,
"external_id": "video-task-o1"
}
}status 可能为 submitted(已提交)、processing(处理中)、succeeded(成功)或 failed(失败)。
| 字段 | 说明 |
|---|---|
code | 错误码;0 表示请求成功。 |
message | 错误或状态信息。 |
request_id | 系统生成的请求 ID,用于跟踪和排查问题。 |
data.id | 系统生成的任务 ID。 |
data.status | 当前任务状态。 |
data.create_time、data.update_time | 创建与更新时间,Unix 毫秒时间戳。 |
data.external_id | 自定义任务 ID(如有)。 |
查询任务
GET https://token.aiznt.com/tasks
task_ids 与 external_task_ids 必须二选一;支持用英文逗号分隔多个 ID。
| 查询参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
task_ids | string | 二选一 | 系统任务 ID;批量查询时以英文逗号分隔。 |
external_task_ids | string | 二选一 | 自定义任务 ID;批量查询时以英文逗号分隔。 |
curl "https://token.aiznt.com/tasks?task_ids=893605946402811985" \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json"响应顶层包含 code、message、request_id 和 data[]。每个任务包含:
| 字段 | 说明 |
|---|---|
id、status、message | 任务 ID、状态及状态信息;失败时 message 给出原因。 |
create_time、update_time | 创建和更新时间,Unix 毫秒时间戳。 |
external_id | 创建任务时传入的自定义任务 ID(如有)。 |
outputs | 生成结果数组,结果 URL 通常在 30 天后清理,请及时保存。 |
billing | 本次任务的计费明细。 |
{
"code": 0,
"message": "string",
"request_id": "string",
"data": [
{
"id": "893605946402811985",
"status": "succeeded",
"message": "string",
"create_time": 1781080778802,
"update_time": 1781080794151,
"external_id": "video-task-o1",
"outputs": [
{
"type": "video",
"id": "string",
"url": "string",
"watermark_url": "string",
"duration": "5"
}
],
"billing": [
{
"charge_type": "cash",
"cash_type": "balance",
"amount": "string",
"currency": "CNY",
"list_price": "string"
}
]
}
]
}outputs[] 按 type 返回不同字段:
video:id、url、watermark_url、duration。image:url、watermark_url、group_id(组图时返回)。audio:id、mp3_url、wav_url、mp3_duration、wav_duration。voice:id、name、url、owned_by、status。element:id、name、description、element_type、references、owned_by、status、tags。
主体结果中的 references[] 可包含 type、role、url;音色引用还可包含 id、name、owned_by。tags[] 包含标签的 id、name 和 description。
billing[] 字段 | 说明 |
|---|---|
charge_type | 扣费账户类型:cash(额度)或 unit(资源包)。 |
cash_type | 额度类型:balance 或 test_balance;仅 charge_type=cash 时返回。 |
amount | 扣减数额;额度场景为折扣价,资源包场景为积分数量。 |
currency | CNY 或 USD;仅额度扣费时返回。 |
package_type | video、image 或 audio;仅资源包扣费时返回。 |
list_price | 额度扣减刊例价;仅额度扣费时返回。 |
游标查询
POST https://token.aiznt.com/tasks
该接口仅支持查询非实时的异步任务。首次查询可使用时间范围和筛选条件;后续分页时,将上一页响应中的 data.next_cursor 作为 cursor 传入。传入 cursor 后,start_time 和 end_time 不再生效。请求体支持 start_time、end_time、cursor、limit 和 filters:
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
start_time | string | end_time 前 30 天 | Unix 毫秒时间戳,必须早于 end_time。 |
end_time | string | 当前时间 | Unix 毫秒时间戳。 |
cursor | string | - | 上次响应的 data.next_cursor;传入后忽略时间范围。 |
limit | integer | 100 | 返回数量,最大 500。 |
filters | array | - | 查询筛选条件数组。 |
filters[].key | string | - | status 或 product_type。 |
filters[].values | array | - | status 可取 submitted、processing、succeeded、failed;product_type 可取 video、image、try_on。 |
curl https://token.aiznt.com/tasks \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"limit": 100,
"filters": [
{
"key": "status",
"values": [
"succeeded"
]
},
{
"key": "product_type",
"values": [
"video"
]
}
]
}'响应数据位于 data.result,并包含 data.count、data.next_cursor 和 data.has_more;result[] 的任务字段与按 ID 查询一致。
需要下一页时,将上一页的 data.next_cursor 放入 cursor:
{
"cursor": "上一次响应中的 data.next_cursor",
"limit": 100,
"filters": [
{
"key": "product_type",
"values": ["video"]
}
]
}