模型接口
创建 Kling Omni 视频
使用 URL 中的模型 ID 创建 Kling Omni 视频任务,然后通过任务 ID 获取结果。
POST
/
omni-video
/
{model}
cURL
curl https://api.cometapi.com/omni-video/kling-3.0-omni \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond.",
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": False,
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/omni-video/{model}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'type' => 'prompt',
'text' => 'A paper boat drifts on a pond.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/omni-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.cometapi.com/omni-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/omni-video/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}使用
对于
响应会返回异步任务的
使用
POST /omni-video/{model} 创建异步 Kling Omni 视频任务。在 URL 中指定模型 ID,并通过 contents 提供输入。
选择模型
kling-4.0:720p或1080p;时长为 3-30 秒;没有audio字段。除固定宽高比外,还支持adaptive宽高比,并接受middle_frame内容。kling-3.0-omni:720p,1080p,或4k;时长为 3-15 秒;支持native、original或off音频。kling-o1:720p或1080p;时长为 3-10 秒;支持original或off音频。
kling-3.0-omni。要创建无声视频,请将 settings.audio 设置为 off。
请求参数
| 字段 | 必填 | 描述 |
|---|---|---|
路径 model | 是 | URL 中的模型 ID。从上方列表中选择一个 ID;不要将其添加到请求正文中。 |
contents | 是 | 非空的视频输入数组。对于纯文本请求,请包含一个 prompt 项。 |
contents[].type | 是 | prompt, first_frame, middle_frame, last_frame, refer_image, feature_video,或 base_video。middle_frame 可与 kling-4.0 一起使用。last_frame 需要一个 first_frame. |
contents[].text | 对于 prompt 项 | 描述视频的文本。 |
contents[].url | 对于图像或视频项 | 图像 URL 或 Base64 图像数据;视频项使用公开视频 URL。 |
settings.resolution | 否 | 输出分辨率。如果省略,请求将使用 720p。可用值取决于 model. |
settings.aspect_ratio | 否 | 画面宽高比:adaptive(仅限 kling-4.0)、16:9、9:16 或 1:1。默认为 16:9. |
settings.duration | 否 | 视频时长,以整数秒为单位。默认为 10,适用于 kling-4.0;其他模型默认为 5。时长必须在所选模型的范围内。请发送整数,而非字符串。 |
settings.multi_shot | 否 | 对于 kling-3.0-omni,设置 true 以使用多个镜头,或设置 false 以使用一个连续镜头。不要为以下模型包含此字段: kling-o1. |
settings.audio | 否 | 根据所选模型和输入,设置 native、original 或 off。以下模型不支持此字段: kling-4.0. |
options.callback_url | 否 | 接收任务状态回调的 HTTPS URL。 |
options.external_task_id | 否 | 用于关联任务的自定义标识符;请保留返回的 data.id 以供查询。 |
options.watermark_info.enabled | 否 | 设为 true 以请求添加水印。 |
kling-4.0,最多允许一个 base_video 内容项。对于 kling-3.0-omni,feature_video 输入需要 settings.multi_shot: true 和 settings.audio: off。base_video 输入需要 settings.multi_shot: false,且不能使用 settings.audio: native。不要将 base_video 与首帧或末帧同时使用。
kling-3.0-omni 的官方默认值为 multi_shot: true;需要指定镜头模式时,请显式设置该字段。对于 kling-o1,Prompt 最多可包含 2500 个字符。如果请求仅包含一个 first_frame,没有其他参考图像或视频,请使用 5 秒或 10 秒的时长。
要创建一个 5 秒的纯文本视频,请将以下请求正文发送到 POST /omni-video/kling-3.0-omni:
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
id:
{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}
data.id 值调用 获取 Kling 任务 ,直到任务完成。从任务的 outputs 数组中读取生成的视频 URL。如果需要持久访问,请将视频存储在自己的存储空间中。
OpenAPI 面板中包含对应的 Shell、Python 和 JavaScript 请求。有关更多输入组合,请参阅 Kling 3.0 Omni 视频 API 参考 或 Kling O1 Omni 视频 API 参考.路径参数
请求体
application/json
Omni video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
最后修改于 2026年11月13日
⌘I
cURL
curl https://api.cometapi.com/omni-video/kling-3.0-omni \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}
JSONimport os
import requests
response = requests.post(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond.",
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": False,
"audio": "off",
},
},
)
response.raise_for_status()
result = response.json()
print(result["data"]["id"])
const response = await fetch(
"https://api.cometapi.com/omni-video/kling-3.0-omni",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"contents": [
{
"type": "prompt",
"text": "A paper boat drifts on a pond."
}
],
"settings": {
"resolution": "720p",
"aspect_ratio": "16:9",
"duration": 5,
"multi_shot": false,
"audio": "off"
}
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
console.log(result.data.id);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/omni-video/{model}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'type' => 'prompt',
'text' => 'A paper boat drifts on a pond.'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/omni-video/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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.cometapi.com/omni-video/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/omni-video/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"type\": \"prompt\",\n \"text\": \"A paper boat drifts on a pond.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "SUCCEED",
"data": {
"id": "example-task-id",
"status": "submitted"
}
}