Kling v2.6 视频生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"mode": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"reference_images": [
"<string>"
],
"image_with_roles": [
{
"url": "<string>",
"role": "<string>"
}
],
"negative_prompt": "<string>",
"audio": true,
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"mode": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"reference_images": ["<string>"],
"image_with_roles": [
{
"url": "<string>",
"role": "<string>"
}
],
"negative_prompt": "<string>",
"audio": True,
"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>',
mode: '<string>',
duration: 123,
aspect_ratio: '<string>',
reference_images: ['<string>'],
image_with_roles: [{url: '<string>', role: '<string>'}],
negative_prompt: '<string>',
audio: true,
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>',
'mode' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'reference_images' => [
'<string>'
],
'image_with_roles' => [
[
'url' => '<string>',
'role' => '<string>'
]
],
'negative_prompt' => '<string>',
'audio' => true,
'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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_bodyKling v2.6
Kling v2.6 视频生成
使用官方 Kling v2.6 生成视频,普通参考图与首尾帧控制采用显式区分语义
POST
/
v1
/
videos
/
generations
Kling v2.6 视频生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"mode": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"reference_images": [
"<string>"
],
"image_with_roles": [
{
"url": "<string>",
"role": "<string>"
}
],
"negative_prompt": "<string>",
"audio": true,
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"prompt": "<string>",
"mode": "<string>",
"duration": 123,
"aspect_ratio": "<string>",
"reference_images": ["<string>"],
"image_with_roles": [
{
"url": "<string>",
"role": "<string>"
}
],
"negative_prompt": "<string>",
"audio": True,
"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>',
mode: '<string>',
duration: 123,
aspect_ratio: '<string>',
reference_images: ['<string>'],
image_with_roles: [{url: '<string>', role: '<string>'}],
negative_prompt: '<string>',
audio: true,
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>',
'mode' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'reference_images' => [
'<string>'
],
'image_with_roles' => [
[
'url' => '<string>',
'role' => '<string>'
]
],
'negative_prompt' => '<string>',
'audio' => true,
'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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\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 \"mode\": \"<string>\",\n \"duration\": 123,\n \"aspect_ratio\": \"<string>\",\n \"reference_images\": [\n \"<string>\"\n ],\n \"image_with_roles\": [\n {\n \"url\": \"<string>\",\n \"role\": \"<string>\"\n }\n ],\n \"negative_prompt\": \"<string>\",\n \"audio\": true,\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body- 异步处理模式,返回任务 ID 供后续查询
- 支持文生视频、图生视频、显式首尾帧控制和有声视频
- 支持标准模式(720P)和专业模式(1080P)
- 专业模式支持自动音频生成
认证
string
必填
所有接口均需要使用 Bearer Token 进行认证。
Authorization: Bearer YOUR_API_KEY
请求参数
string
必填
视频生成模型名称,固定为
kling-v2-6。string
必填
文字提示词,最多 2500 字符。
string
默认值:"std"
生成模式。
std- 标准模式(720P,仅支持静音视频)pro- 专业模式(1080P,支持自动音频生成)
integer
默认值:"5"
视频时长(秒)。可选值:
5 或 10string
默认值:"16:9"
视频宽高比。常用值:
16:9、9:16、1:1string[]
普通参考图。
- 这里只表示参考图语义
- 不会再自动把第二张参考图推断为尾帧
- 首尾帧请使用
image_with_roles显式传入
object[]
string
负面提示词,描述不希望出现的内容。
boolean
默认值:"false"
是否自动生成音频。
仅在
mode: "pro" 下可用。boolean
是否添加水印。
输入规则
| 输入形态 | 行为 |
|---|---|
只有 reference_images | 普通参考图 |
只有 image_with_roles 且角色仅有 first_frame / last_frame | 首尾帧控制 |
| 两者混用,或 roles 中同时含 frame/reference 语义 | 混合模式 |
示例
文生视频
{
"model": "kling-v2-6",
"prompt": "一只金色的猫咪在阳光普照的草地上奔跑,慢动作,电影质感",
"mode": "std",
"duration": 5,
"aspect_ratio": "16:9"
}
普通参考图
{
"model": "kling-v2-6",
"prompt": "参考人物形象,让角色轻轻微笑",
"reference_images": ["https://example.com/reference.jpg"],
"mode": "std",
"duration": 5
}
首尾帧控制
{
"model": "kling-v2-6",
"prompt": "城市延时摄影,从白天过渡到夜晚",
"image_with_roles": [
{ "url": "https://example.com/day-city.jpg", "role": "first_frame" },
{ "url": "https://example.com/night-city.jpg", "role": "last_frame" }
],
"mode": "pro",
"duration": 5
}
参考图与首尾帧混合
{
"model": "kling-v2-6",
"prompt": "保持角色一致性,同时完成场景过渡",
"reference_images": ["https://example.com/character-reference.jpg"],
"image_with_roles": [
{ "url": "https://example.com/start-scene.jpg", "role": "first_frame" },
{ "url": "https://example.com/end-scene.jpg", "role": "last_frame" }
],
"mode": "pro",
"duration": 5
}
专业模式 + 自动音频
{
"model": "kling-v2-6",
"prompt": "海浪拍打礁石,海鸥在空中盘旋,远处有一座灯塔",
"mode": "pro",
"duration": 10,
"audio": true,
"aspect_ratio": "16:9"
}
视频生成为异步任务。使用 获取视频任务状态 接口查询生成进度和结果。
⌘I