1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const axios = require('axios');
const FormData = require('form-data');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/kling-2";
const reqBody = {
"prompt": "A photograph of a giant panda swimming in a crystal-clear outdoor pool. The panda is gracefully paddling with its black and white fur glistening in the sunlight, its playful expression clearly visible. The pool is surrounded by lush green foliage and colorful flowers, with a wooden deck leading to a grassy lawn. Soft, natural light bathes the scene, highlighting the water's clarity and the panda's movements.",
"duration": 5,
"cfg_scale": 0.5,
"start_image": "https://segmind-resources.s3.amazonaws.com/input/65a44af9-de76-474e-898f-57e83b0ff3b3-a-photograph-of-a-giant-panda-swimming-i_k_2X05UAQYWIOoZJLuVpyg_eFEiq19KSYO9FzXR4tdibQ.jpeg",
"aspect_ratio": "16:9"
};
(async function() {
try {
const formData = new FormData();
// Append regular fields
for (const key in reqBody) {
if (reqBody.hasOwnProperty(key)) {
formData.append(key, reqBody[key]);
}
}
// Convert and append images as Base64 if necessary
const response = await axios.post(url, formData, {
headers: {
'x-api-key': api_key,
...formData.getHeaders()
}
});
console.log(response.data);
} catch (error) {
console.error('Error:', error.response ? error.response.data : error.message);
}
})();
Prompt for video generation
Number of second of video to be generated.
Allowed values:
Flexibility in video generation: Higher values reduce flexibility but increase adherence to the user's prompt.
min : 0,
max : 1
Input image that acts as the starting frame for the generated video. Get best results with16:9 or 9:16 and 1280x720 or 720x1280, depending on the aspect ratio you choose.
Aspect ratio of the output video
Allowed values:
Prompt to exclude from the generated video
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
Kling 2.0 is a state-of-the-art AI video generation model developed by Kling AI (Kuaishou), officially released in April 2025. It represents a significant leap forward in generative video and image technology, delivering professional-grade results for creators, marketers, educators, and anyone seeking high-quality, customizable video content.
Kling 2.0 is an upgrade to Kling 1.6 to generate videos from text prompts or reference images. Its core strength lies in transforming detailed user instructions into visually rich, dynamic, and realistic video sequences. The model excels at understanding complex prompts, interpreting nuanced actions, and simulating sophisticated camera movements, all while maintaining high visual fidelity and stylistic consistency.
Kling 2.0 is versatile and fits a wide range of creative and professional scenarios:
Kling 2.0 stands out as a next-generation AI creative tool, combining advanced video generation, precise prompt adherence, cinematic visuals, and powerful editing capabilities. It empowers users-from solo creators to large enterprises-to produce, customize, and iterate on professional-quality video content with ease, making it a leading choice in the evolving landscape of AI-driven media production.