kling-3.0-turbo 视频生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"reference_images": [
"<string>"
],
"resolution": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"reference_images": ["<string>"],
"resolution": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"watermark": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
reference_images: ['<string>'],
resolution: '<string>',
duration: 123,
aspect_ratio: '<string>',
watermark: true
})
};
fetch('https://toapis.com/v1/videos/generations', 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://toapis.com/v1/videos/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'reference_images' => [
'<string>'
],
'resolution' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'watermark' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://toapis.com/v1/videos/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://toapis.com/v1/videos/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/videos/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_bodykling-3.0-turbo
kling-3.0-turbo 视频生成
通过 ToAPIs 标准异步视频接口接入官方 kling-3.0-turbo 视频生成模型
POST
/
v1
/
videos
/
generations
kling-3.0-turbo 视频生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"reference_images": [
"<string>"
],
"resolution": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"reference_images": ["<string>"],
"resolution": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"watermark": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
reference_images: ['<string>'],
resolution: '<string>',
duration: 123,
aspect_ratio: '<string>',
watermark: true
})
};
fetch('https://toapis.com/v1/videos/generations', 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://toapis.com/v1/videos/generations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'prompt' => '<string>',
'reference_images' => [
'<string>'
],
'resolution' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'watermark' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://toapis.com/v1/videos/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://toapis.com/v1/videos/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/videos/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"resolution\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body- 异步任务接口,提交后返回任务 ID
- 使用新的官方 Kling Turbo 上游协议
- 支持文生视频和图生视频,但图生仅支持首帧
resolution支持720p和1080pduration支持3s、4s、5s、6s、7s、8s、9s、10s、11s、12s、13s、14s、15saspect_ratio仅对文生视频生效watermark仅支持布尔开关,不支持自定义水印对象
请传入公网可访问的图片 URL。不要直接传 base64 图片数据;本地图片请先使用 上传图片接口 获取 URL。
认证
string
必填
所有接口均需要使用 Bearer Token 认证。
Authorization: Bearer YOUR_API_KEY
请求参数
string
必填
视频生成模型名称,固定为
kling-3.0-turbo。string
必填
视频提示词。对于图生视频,该字段会转换为 Kling Turbo
contents 中的 prompt 项。string[]
可选输入图片。Kling Turbo 图生视频只会取第一张图作为
first_frame。当前接入不支持尾帧。多余图片不会作为尾帧传给上游。
string
默认值:"720p"
视频分辨率。支持值:
720p1080p
integer
默认值:"5"
视频时长,单位秒。支持值:
3、4、5、6、7、8、9、10、11、12、13、14、15string
默认值:"16:9"
文生视频宽高比。支持值:
16:99:161:1
boolean
默认值:"false"
是否添加官方 Kling 水印。
示例
文生视频
{
"model": "kling-3.0-turbo",
"prompt": "A cinematic shot of a red sports car driving through rain",
"resolution": "720p",
"duration": 5,
"aspect_ratio": "16:9"
}
图生视频
{
"model": "kling-3.0-turbo",
"prompt": "Animate the character with subtle camera motion",
"reference_images": ["https://example.com/first-frame.png"],
"resolution": "1080p",
"duration": 5,
"watermark": true
}
视频生成为异步任务。提交后使用 获取视频任务状态 查询进度和结果。
⌘I