Kling 官方接口
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body视频系列
Kling 官方接口
Kling(可灵)视频生成官方接口(V1 风格 / 3.0 官方风格)
POST
{llmApiOrigin}
/
kling
/
v1
/
videos
/
text2video
Kling 官方接口
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video"
headers = {"Authorization": "<authorization>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/kling/v1/videos/text2video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body简介
Kling 官方接口以可灵官方 API 风格提供文生视频、图生视频与 Omni(多参考输入)能力,通过 可灵 Kling 或腾讯 TokenHub 渠道分发。共有两套入口:- V1 风格:
/kling/v1/videos/...,模型写在请求体里; - 3.0 官方风格:
/kling/text-to-video/kling-3.0等,模型在 URL 路径里,查询使用GET /kling/tasks。
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxxKling V1 风格
| 方法 | 路径 | 说明 |
|---|---|---|
POST | /kling/v1/videos/text2video | 提交文生视频任务 |
POST | /kling/v1/videos/image2video | 提交图生视频任务 |
GET | /kling/v1/videos/text2video/{task_id} | 查询文生视频任务 |
GET | /kling/v1/videos/image2video/{task_id} | 查询图生视频任务 |
支持模型(V1)
| 模型 | 说明 |
|---|---|
kling-v1、kling-v1-6 | Kling 基础版本 |
kling-v2-master | Kling V2 |
kling-v2-6、kling-v2-5-turbo | Kling V2 系列 |
kling-v3 | Kling V3 |
提交任务(V1)
POST/kling/v1/videos/text2video 或 /kling/v1/videos/image2video
文生视频
curl -X POST "https://api.shengmoai.com/kling/v1/videos/text2video" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-v3",
"prompt": "一只灰白相间的猫在草地上打滚,阳光明媚",
"duration": 5
}'
图生视频
curl -X POST "https://api.shengmoai.com/kling/v1/videos/image2video" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-F "model=kling-v3" \
-F "prompt=人物的衣角随风飘动,镜头缓慢拉近" \
-F "duration=5" \
-F "image=@cat.png"
metadata 透传:
{
"model": "kling-v3",
"prompt": "...",
"duration": 5,
"metadata": {
"aspect_ratio": "16:9",
"negative_prompt": "低质量,模糊,变形",
"sound": false,
"seed": 12345
}
}
请求参数(V1)
| 字段 | 类型 | 说明 |
|---|---|---|
model | string | 模型标识(必须) |
prompt | string | 提示词(必须) |
image / images | string/array | 图生视频输入(URL 或 Base64),也可 multipart 上传 input_reference |
duration | integer | 时长(秒),默认 5 |
size | string | 尺寸,1024x1024 → 1:1、1280x720 → 16:9、720x1280 → 9:16 |
mode | string | std 标准 / pro 专业(professional) |
metadata | object | 透传:aspect_ratio、negative_prompt、cfg_scale、static_mask、dynamic_masks、camera_control、callback_url、external_task_id 等 |
提交响应(V1)
任务接受后返回视频任务对象(task_id 用于查询):
{
"id": "task_1234567890",
"task_id": "task_1234567890",
"object": "video",
"model": "kling-v3",
"status": "queued",
"created_at": 1782642668
}
查询任务(V1)
GET/kling/v1/videos/text2video/{task_id}(或 image2video):
curl "https://api.shengmoai.com/kling/v1/videos/text2video/task_1234567890" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
status 取值语义:
| 状态 | 说明 |
|---|---|
queued | 排队中 |
processing / in_progress | 生成中 |
succeeded / completed | 成功 |
failed | 失败 |
Kling 3.0 官方风格
模型标识在 URL 路径中,请求体其余字段(含未知字段)原样透传。| 方法 | 路径 | 场景 |
|---|---|---|
POST | /kling/text-to-video/kling-3.0 | 文生视频 |
POST | /kling/image-to-video/kling-3.0 | 图生视频 |
POST | /kling/text-to-video/kling-3.0-turbo | 文生视频(Turbo) |
POST | /kling/image-to-video/kling-3.0-turbo | 图生视频(Turbo) |
POST | /kling/omni-video/kling-3.0-omni | Omni(多参考输入) |
GET | /kling/tasks?task_ids={task_id} | 查询任务(官方 envelope) |
GET | /kling/tasks?external_task_ids={external_id} | 按外部任务 ID 查询 |
支持模型(3.0)
| 模型 | 说明 |
|---|---|
kling-3.0 | Kling 3.0 标准 |
kling-3.0-turbo | Kling 3.0 Turbo |
kling-3.0-omni | Kling 3.0 Omni(多参考输入) |
提交任务(3.0)
POST/kling/text-to-video/kling-3.0(或按场景选择 image-to-video / omni-video):
curl -X POST "https://api.shengmoai.com/kling/text-to-video/kling-3.0" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"prompt": "一只灰白相间的猫在草地上打滚,阳光明媚",
"duration": 5,
"options": {
"external_task_id": "my-order-123",
"callback_url": "https://your-domain.com/kling-callback"
}
}'
请求参数(3.0)
| 字段 | 类型 | 说明 |
|---|---|---|
prompt | string | 提示词(必须) |
image / images | string/array | 图生视频 / Omni 的媒体输入(URL 或 Base64,Omni 场景也支持参考视频) |
duration | integer | 时长(秒),默认 5,范围 3-15 |
resolution | string | 分辨率,默认 720p |
options.external_task_id | string | 可选外部任务 ID:1-191 个 ASCII 字母/数字/-/_/. |
options.callback_url | string | 可选回调地址:必须是绝对 HTTPS URL |
seed、画幅等)会原样透传给上游。
Omni 输入限制
- 最多 1 个参考视频;
- 无参考视频时,参考图等输入最多 7 个;
- 有参考视频时,参考输入最多 4 个。
查询任务(3.0)
GET/kling/tasks?task_ids={task_id}(或 external_task_ids=),一次只支持查询一个任务:
curl "https://api.shengmoai.com/kling/tasks?task_ids=task_1234567890" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
{
"code": 0,
"message": "success",
"request_id": "req-xxxx",
"data": [
{
"id": "task_1234567890",
"status": "succeeded",
"create_time": 1782642668000,
"update_time": 1782642876000,
"external_id": "my-order-123",
"outputs": [
{ "url": "https://example-cdn.com/result.mp4", "duration": 5 }
]
}
]
}
data[].status 取值:submitted、processing、succeeded、failed。失败时 data[].error 携带 code/message;时间为 Unix 毫秒。
回调(3.0)
服务端通过options.callback_url 配置后,会在任务状态变化时向你的回调地址发送通知。回调以 HMAC 签名保护,无 Token 鉴权,请求体为 application/json(≤1 MiB):
POST /kling/callbacks/{task_id}/{signature}
{"code": 0, "message": "success"} 确认;返回 5xx 会触发上游重试。
相关页面
视频生成总览
异步流程与入口选择
视频内容获取
下载与代理获取视频文件
