Kling 文生视频
curl --request POST \
--url https://api.mixroute.ai/kling/text-to-video/{model}import requests
url = "https://api.mixroute.ai/kling/text-to-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/text-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/text-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/text-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/text-to-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/text-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 文生视频的提示词、音频、画幅和时长参数。
Kling 文生视频
curl --request POST \
--url https://api.mixroute.ai/kling/text-to-video/{model}import requests
url = "https://api.mixroute.ai/kling/text-to-video/{model}"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.mixroute.ai/kling/text-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/text-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/text-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/text-to-video/{model}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mixroute.ai/kling/text-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,以
3.0 和 3.0 Turbo 的分镜格式为
通用选项见 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 |
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | 是 | 非空文本,可包含正向和负向描述。3.0/3.0 Turbo 最多 3072 字符,建议不超过 2500;2.6/2.5 Turbo 最多 2500。 |
settings.resolution | string | 否 | 默认 720p;按上表选择小写 720p、1080p 或 4k。 |
settings.duration | integer | 否 | 默认 5。3.0/3.0 Turbo 为 3-15 的整数;2.6/2.5 Turbo 仅 5 或 10。 |
settings.aspect_ratio | string | 否 | 16:9(默认)、9:16 或 1:1。 |
settings.audio | string | 否 | 仅 3.0/2.6:off(默认)或 native;2.6 使用 native 必须设 1080p。3.0 Turbo 内置音频,不传此字段;2.5 Turbo 不支持此字段。 |
settings.multi_shot | boolean | 否 | 仅 3.0:默认 true;false 禁用多镜头生成。Turbo 不提供此开关,可通过分镜提示词控制。 |
shot n, m, words;:1-6 个镜头,每个至少 1 秒,镜头时长之和等于总时长,每镜提示词最多 512 字符。图像素材不要传入文生端点。
请求示例
先设置环境变量MIXROUTE_API_KEY。将 example.com 媒体地址替换为无需登录即可访问的真实素材。
curl --request POST "https://api.mixroute.ai/kling/text-to-video/kling-3.0" \
--header "Authorization: Bearer $MIXROUTE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"prompt": "A red ceramic mug slowly rotates on a white tabletop. Static camera, soft studio lighting.",
"settings": {
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9",
"audio": "off",
"multi_shot": false
},
"options": {
"watermark_info": {
"enabled": false
}
}
}'
提交响应
{
"code": 0,
"message": "",
"request_id": "REQUEST_ID",
"data": {
"id": "task_example",
"status": "submitted"
}
}
data.id,使用 查询 Kling 任务 轮询至 succeeded 或 failed。提交成功不代表生成完成。