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。提交成功不代表生成完成。