مسارات النماذج
إنشاء فيديو Kling Omni
أنشئ مهمة فيديو Kling Omni باستخدام معرّف النموذج في عنوان URL، ثم استرجع النتيجة باستخدام معرّف المهمة.
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 وقدّم الإدخال في 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. اختر معرّفًا من القائمة أعلاه؛ ولا تضفه إلى متن الطلب. |
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 | لا | عنوان URL يستخدم HTTPS ويتلقى إشعارات حالة المهمة. |
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 حتى تكتمل المهمة. اقرأ عنوان URL للفيديو المكتمل من مصفوفة outputs الخاصة بالمهمة. خزّن الفيديو في مساحة التخزين الخاصة بك إذا كنت بحاجة إلى وصول دائم إليه.
تحتوي لوحة OpenAPI على طلبات مكافئة بلغات Shell وPython وJavaScript. للاطلاع على المزيد من مجموعات المدخلات، راجع مرجع API للفيديو Kling 3.0 Omni أو مرجع API للفيديو Kling O1 Omni.معلمات المسار
الجسم
application/json
Omni video request fields exposed by the CometAPI route. The model ID is a path parameter, not a body field.
الاستجابة
200 - application/json
Task created. Store data.id for a GET /tasks query.
آخر تعديل في ١٣ نوفمبر ٢٠٢٦
⌘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"
}
}