Kling Omniによる生成と編集
curl --request POST \
--url https://api.mixroute.ai/kling/omni-video/{model}import requests
url = "https://api.mixroute.ai/kling/omni-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/omni-video/{model}', 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.mixroute.ai/kling/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",
]);
$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.mixroute.ai/kling/omni-video/{model}"
req, _ := http.NewRequest("POST", url, nil)
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.mixroute.ai/kling/omni-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/omni-video/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyKling
Kling Omniによる生成と編集
Kling 3.0 OmniとO1による画像/動画の参照と動画編集。
Kling Omniによる生成と編集
curl --request POST \
--url https://api.mixroute.ai/kling/omni-video/{model}import requests
url = "https://api.mixroute.ai/kling/omni-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/omni-video/{model}', 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.mixroute.ai/kling/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",
]);
$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.mixroute.ai/kling/omni-video/{model}"
req, _ := http.NewRequest("POST", url, nil)
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.mixroute.ai/kling/omni-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/omni-video/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_bodyAuthorization: Bearer $MIXROUTE_API_KEYを使用してMixRouteのAPIキーで認証し、JSONを送信してください。モデルIDはボディのmodelフィールドではなく、URLに含めます。/v1を追加したり、リクエストをmetadataで囲んだりしないでください。
対応モデル
| モデルID | 解像度 | 標準生成の動画の長さ(秒) |
|---|---|---|
| kling-3.0-omni | 720p / 1080p / 4k | 3-15 |
| kling-o1 | 720p / 1080p | 3-10 |
内容
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
contents | object[] | はい | テキストおよびマルチモーダル入力。テキストから生成する場合は、プロンプトのみを含めることができます。 |
contents[].type | string | はい | 項目ごとに必須:prompt、first_frame、last_frame、refer_image、feature_video、base_video、またはelement。 |
contents[].text | string | 種類別 | prompt項目に必須です。3.0 Omni:最大3072文字(2500文字を推奨)。O1:最大2500文字。IDの参照には@image_1または@video_1を使用してください。 |
contents[].url | string | 種類別 | 画像/動画の項目では必須です。画像はURLまたはBase64を受け付け、動画には公開URLを使用します。feature_videoは特徴の参照用動画を、base_videoは編集対象の動画を指定します。 |
contents[].element_id | string | 種類別 | element項目では必須で、ルーティング先の上流アカウントからアクセスできる必要があります。 |
contents[].id | string | 種類別 | element項目では必須です。image/video項目では任意ですが、プロンプト内で参照する場合は設定してください。タスク内で一意である必要があります。 |
生成設定
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
settings.resolution | string | いいえ | デフォルトは720pです。3.0 Omni:720p/1080p/4k。O1:720p/1080p。 |
settings.duration | integer | いいえ | デフォルトは5です。3.0 Omni: 3~15。O1: 3~10。O1で最初のフレームのみを使用し、refer_image/videoの参照がない場合は、5秒または10秒のみ対応します。 |
settings.aspect_ratio | string | シナリオによる | 16:9(デフォルト)、9:16、または1:1。最初のフレームも参照動画もない場合は、明示的に指定してください。 |
settings.audio | string | いいえ | デフォルトはoff。3.0 Omni: native/original/off。O1: original/off。originalは参照動画の音声を保持します。3.0 Omniでは、動画入力とnativeを併用できません。 |
settings.multi_shot | boolean | いいえ | 3.0 Omniのみで、デフォルトはtrueです。feature_videoではtrueが必須です。マルチショットに対応しないbase_video編集ではfalseに設定してください。O1では省略してください。 |
入力の組み合わせ
- どちらのモデルも動画は最大1本までです。base_videoによる編集では、最初または最後のフレームを含めることはできません。
- 最初のフレームのみ、または最初と最後のフレームを使用し、最後のフレームだけを使用しないでください。O1の最初と最後のフレームを使うモードでは、参照画像やElementsを含めることはできません。O1のfeature_videoには最初のフレームを含められますが、最後のフレームは含められません。
- O1は複数画像のElementのみをサポートします。動画がない場合は参照画像とElementを合わせて最大7つ、動画がある場合は最大4つです。
- 動画を使用しない3.0 Omniでは、参照画像と複数画像のElementを合わせて最大7つ使用できます。動画キャラクターのElementを使用する場合は、動画キャラクターのElementを最大3つ、参照画像と複数画像のElementを合わせて最大4つ使用してください。
- 3.0 Omniで動画を使用する場合、参照画像と複数画像のElementsは合計最大4つ、または動画キャラクターのElementは1つまで使用できます。この場合、動画キャラクターのElementを画像や複数画像のElementsと組み合わせないでください。最初のフレーム、または最初と最後のフレームを指定する生成では、最大3つのElementsを使用できます。
- 3.0 Omniのfeature_videoにはaudio=offが必要です。base_videoではoffまたはoriginalを使用します。ネイティブ音声は、動画入力がない場合にのみ利用できます。
メディアの制限
| 入力 | 制限 |
|---|---|
| 画像 | JPG/JPEG/PNG、最大50 MB。縦横ともに300 px以上、アスペクト比は1:2.5~2.5:1。 |
| 3.0 Omni動画 | MP4/MOV、最大200 MB、3~15.5秒。各辺700~4553 px、総面積は最大8294400ピクセル。アスペクト比0.4~2、24~60 fps。 |
| O1動画 | MP4/MOV、最大200 MB、3~10秒。各辺700~2160 px、24~60 fps。 |
ストーリーボードのプロンプト
マルチショット生成をサポートするのは3.0 Omniのみです。settings.multi_shotを有効にして、セミコロンで区切ったshot n, m, words;を使用します。ショット数は1~6、各ショットは1秒以上、長さの合計はsettings.durationと一致させ、各ショットのプロンプトは512文字以内にします。このモードはbase_video編集では使用できません。O1にマルチショットのパラメータを送信しないでください。参照名は一意にし、相互に、または無関係なプロンプトのテキストと重複しないようにしてください。
画像参照の例
環境変数MIXROUTE_API_KEYを設定してください。example.comのメディアURLは、実際の公開アクセス可能なファイルに置き換えてください。
curl --request POST "https://api.mixroute.ai/kling/omni-video/kling-3.0-omni" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"contents": [
{
"type": "prompt",
"text": "The mug in @image_1 slowly rotates on a white tabletop. Soft studio lighting."
},
{
"type": "refer_image",
"url": "https://example.com/reference.png",
"id": "image_1"
}
],
"settings": {
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9",
"audio": "native",
"multi_shot": false
}
}'
O1の動画編集例
curl --request POST "https://api.mixroute.ai/kling/omni-video/kling-o1" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"contents": [
{
"type": "prompt",
"text": "Change the red mug in @video_1 to blue. Preserve the original motion and background."
},
{
"type": "base_video",
"url": "https://example.com/source.mp4",
"id": "video_1"
}
],
"settings": {
"resolution": "720p",
"duration": 5,
"audio": "off"
}
}'
送信時のレスポンス
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "task_example",
"status": "submitted"
}
}
data.idを保持し、succeededまたはfailedになるまでKlingタスクの照会を使用してください。送信の成功は、生成の完了を意味しません。