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_body使用 MixRoute API Key,以
普通圖生端點不提供
通用選項見 Kling 概覽。
儲存
Authorization: Bearer $MIXROUTE_API_KEY 認證,請求體為 JSON。模型 ID 位於 URL 中,不在請求體中重複傳 model;不新增 /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 與附屬欄位放在同一物件。 |
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 個 Element。 |
contents[].voice_id | string | 按型別 | voice 項必填,2.6 最多引用 2 個音色,須使用 audio=native 與 1080p。 |
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,單張不超過 50 MB,寬和高均至少 300 px,寬高比介於 1:2.5 和 2.5:1。使用首幀或首幀+尾幀;不要只傳尾幀。資產 ID 的可訪問性取決於上游路由賬戶。請求示例
先設定環境變數MIXROUTE_API_KEY。將 example.com 媒體地址替換為無需登入即可訪問的真實素材。
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,使用 查詢 Kling 任務 輪詢至 succeeded 或 failed。提交成功不代表生成完成。