Klingの画像から動画への生成
curl --request POST \
--url https://api.mixroute.ai/kling/image-to-video/{model}import requests
url = "https://api.mixroute.ai/kling/image-to-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/image-to-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/image-to-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/image-to-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/image-to-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/image-to-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の画像から動画への生成
Klingの最初のフレーム、最初/最後のフレーム、Element、および音声の入力。
Klingの画像から動画への生成
curl --request POST \
--url https://api.mixroute.ai/kling/image-to-video/{model}import requests
url = "https://api.mixroute.ai/kling/image-to-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/image-to-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/image-to-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/image-to-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/image-to-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/image-to-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 | 720p / 1080p / 4k | 3-15 |
| kling-3.0-turbo | 720p / 1080p | 3-15 |
| kling-2.6 | 720p / 1080p | 5 / 10 |
| kling-2.5-turbo | 720p / 1080p | 5 / 10 |
内容
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
contents | object[] | はい | 入力の集合。最初のフレームは必須です。最後のフレームのみの入力には対応していません。各typeとそれに対応するフィールドを1つのオブジェクトにまとめてください。 |
contents[].type | string | はい | 項目ごとに必須です。prompt、first_frame。last_frameは3.0/2.6/2.5 Turbo、elementは3.0のみ、voiceは2.6のみに対応します。 |
contents[].text | string | 種類別 | prompt項目では必須です。3.0: 最大3072文字(2500文字を推奨)。その他のモデル: 最大2500文字。 |
contents[].url | string | 種類別 | first_frame/last_frameでは必須: 公開画像URLまたはBase64。 |
contents[].element_id | string | 種類別 | element項目では必須です。3.0は最大3つのElementsに対応します。 |
contents[].voice_id | string | 種類別 | voice項目では必須です。2.6は、audio=nativeかつ1080pの場合、最大2つの声に対応します。 |
contents[].id | string | 種類別 | element/voice項目では必須で、タスク内で一意である必要があります。プロンプトでは@idとして参照します。 |
生成設定
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
settings.resolution | string | いいえ | デフォルトは720p。3.0: 720p/1080p/4k。その他のモデル: 720p/1080p。2.6/2.5 Turboの最初と最後のフレームを使うモードでは1080pが必要です。 |
settings.duration | integer | いいえ | デフォルトは5。3.0/3.0 Turboでは3~15、2.6/2.5 Turboでは5または10のみです。 |
settings.audio | string | いいえ | 3.0/2.6はoff(デフォルト)またはnativeをサポートします。2.6のネイティブ音声には1080pが必要です。3.0 Turboと2.5 Turboでは省略してください。 |
settings.multi_shot | boolean | いいえ | 3.0のみ。デフォルトはtrue。falseにすると、ストーリーボード形式のプロンプトを使用してもマルチショット出力が行われなくなります。 |
aspect_ratioがありません。フレーミングは画像に従います。3.0 Turboは最初のフレームのみを受け付け、最後のフレーム、Element、音声参照は受け付けません。3.0のElementは@idとして参照し、名前が重複しないようにしてください。ストーリーボードの構文はテキストから動画への生成と同じです。
画像の制限
JPG/JPEG/PNGに対応し、画像1枚あたり最大50 MB、縦横ともに300 px以上、アスペクト比は1:2.5から2.5:1の範囲です。最初のフレーム、または最初と最後のフレームを指定してください。最後のフレームだけを指定することはできません。アセットIDは、ルーティング先の上流アカウントからアクセスできる必要があります。リクエスト例
環境変数MIXROUTE_API_KEYを設定してください。example.comのメディアURLは、実際の公開アクセス可能なファイルに置き換えてください。
curl --request POST "https://api.mixroute.ai/kling/image-to-video/kling-3.0" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"contents": [
{
"type": "prompt",
"text": "A closed gift box slowly opens to reveal a ceramic mug."
},
{
"type": "first_frame",
"url": "https://example.com/first.png"
},
{
"type": "last_frame",
"url": "https://example.com/last.png"
}
],
"settings": {
"resolution": "1080p",
"duration": 5,
"audio": "native",
"multi_shot": false
}
}'
送信時のレスポンス
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "task_example",
"status": "submitted"
}
}
data.idを保持し、succeededまたはfailedになるまでKlingタスクの照会を使用してください。送信の成功は、生成の完了を意味しません。