Kling v3 Video Generation
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>"
}
],
"audio": true,
"metadata": {
"negative_prompt": "<string>",
"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>"
}
],
"audio": True,
"metadata": {
"negative_prompt": "<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>',
mode: '<string>',
duration: 123,
aspect_ratio: '<string>',
reference_images: ['<string>'],
image_with_roles: [{url: '<string>', role: '<string>'}],
audio: true,
metadata: {negative_prompt: '<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>',
'mode' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'reference_images' => [
'<string>'
],
'image_with_roles' => [
[
'url' => '<string>',
'role' => '<string>'
]
],
'audio' => true,
'metadata' => [
'negative_prompt' => '<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 \"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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\n}"
response = http.request(request)
puts response.read_bodyKling v3
Kling v3 Video Generation
Generate videos with official Kling v3 using explicit reference-image and frame-role semantics
POST
/
v1
/
videos
/
generations
Kling v3 Video Generation
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>"
}
],
"audio": true,
"metadata": {
"negative_prompt": "<string>",
"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>"
}
],
"audio": True,
"metadata": {
"negative_prompt": "<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>',
mode: '<string>',
duration: 123,
aspect_ratio: '<string>',
reference_images: ['<string>'],
image_with_roles: [{url: '<string>', role: '<string>'}],
audio: true,
metadata: {negative_prompt: '<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>',
'mode' => '<string>',
'duration' => 123,
'aspect_ratio' => '<string>',
'reference_images' => [
'<string>'
],
'image_with_roles' => [
[
'url' => '<string>',
'role' => '<string>'
]
],
'audio' => true,
'metadata' => [
'negative_prompt' => '<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 \"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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\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 \"audio\": true,\n \"metadata\": {\n \"negative_prompt\": \"<string>\",\n \"watermark\": true\n }\n}"
response = http.request(request)
puts response.read_body- Async task API, returns a task ID after submission
- Supports text-to-video, image-to-video, explicit first/last frame control, and audio video
mode=stdmaps to 720P,mode=promaps to 1080Paudio=truegenerates an audio video and is billed as Sounddurationsupports3s,4s,5s,6s,7s,8s,9s,10s,11s,12s,13s,14s,15s
Use publicly accessible image URLs. Do not pass base64 image data. Upload local images with the Upload Image API first.
Authorization
string
required
All endpoints require Bearer Token authentication.
Authorization: Bearer YOUR_API_KEY
Request Parameters
string
required
Video generation model name, fixed as
kling-v3.string
required
Text prompt. Describe the subject, action, scene, camera movement, and style.
string
default:"std"
Generation mode.
std- standard mode, 720Ppro- professional mode, 1080P
integer
default:"5"
Video duration in seconds.Options:
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15string
default:"16:9"
Video aspect ratio. Common values:
16:9, 9:16, 1:1string[]
Normal reference images.
- These images are treated as references only
- They are not automatically converted into first/last frames
- Use
image_with_rolesfor explicit frame control
object[]
Explicit image-role array for frame control and mixed inputs.
Show Show image_with_roles object fields
Show Show image_with_roles object fields
last_frame is only sent when explicitly declared in image_with_roles. The system no longer infers the last frame from reference_images[1].boolean
default:"false"
Whether to generate an audio video.
object
Input Rules
| Input shape | Behavior |
|---|---|
reference_images only | Normal references |
image_with_roles with only first_frame / last_frame | Frame control |
| Both fields used together, or roles include both frame and reference semantics | Mixed mode |
Examples
Text-to-Video
{
"model": "kling-v3",
"prompt": "A golden cat running on a sunlit meadow, slow motion, cinematic quality",
"mode": "std",
"duration": 5,
"aspect_ratio": "16:9"
}
Image Reference
{
"model": "kling-v3",
"prompt": "Use the reference character and animate a subtle smile",
"reference_images": ["https://example.com/reference.jpg"],
"mode": "std",
"duration": 5
}
First and Last Frame Control
{
"model": "kling-v3",
"prompt": "The city naturally transitions from day to night",
"image_with_roles": [
{ "url": "https://example.com/day.jpg", "role": "first_frame" },
{ "url": "https://example.com/night.jpg", "role": "last_frame" }
],
"mode": "pro",
"duration": 5
}
Mixed Reference and Frame Input
{
"model": "kling-v3",
"prompt": "Keep the character identity consistent while transitioning scenes",
"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
}
Audio Video
{
"model": "kling-v3",
"prompt": "A singer performing on stage, crowd cheering, flashing lights",
"mode": "std",
"duration": 5,
"audio": true
}
Video generation is asynchronous. Use the Get Video Task Status endpoint to query progress and results.
⌘I