模型介面
建立 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 影片任務。將模型 ID 放在 URL 中,並在 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 | 否 | 影片長度,以整數秒為單位。kling-4.0 的預設值為 10,其他模型的預設值為 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 秒的長度。
若要建立一段五秒的純文字影片,請將此請求主體傳送至 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"
}
}