Kling AI Text to Video Serverless API
Kling AI Text-to-Video is a cutting-edge AI tool that transforms text into stunning, lifelike videos. Create professional-quality content effortlessly with Kling AI's advanced capabilities.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/kling-text2video"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "A border collie, wearing clothes made of laser film, wearing a headset, VR glasses, with the Milky Way reflected in his eyes, classic black and white, high-definition quality, surrealism, microcomputer, hacker dress, cyber style, anthropomorphism, reality",
12 "negative_prompt": "No buildings, no artificial objects",
13 "cfg_scale": 0.5,
14 "mode": "std",
15 "aspect_ratio": "16:9",
16 "duration": "5"
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/kling-text2video"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "A border collie, wearing clothes made of laser film, wearing a headset, VR glasses, with the Milky Way reflected in his eyes, classic black and white, high-definition quality, surrealism, microcomputer, hacker dress, cyber style, anthropomorphism, reality",
12 "negative_prompt": "No buildings, no artificial objects",
13 "cfg_scale": 0.5,
14 "mode": "std",
15 "aspect_ratio": "16:9",
16 "duration": "5"
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)API Endpoint
https://api.segmind.com/v1/kling-text2videoParameters
promptrequiredstringText prompt to describe the desired image
"A border collie, wearing clothes made of laser film, wearing a headset, VR glasses, with the Milky Way reflected in his eyes, classic black and white, high-definition quality, surrealism, microcomputer, hacker dress, cyber style, anthropomorphism, reality"aspect_ratiooptionalstringAspect ratio of the output image
"16:9""16:9""9:16""1:1"camera_control_configoptionalstringContains 6 Fields, used to specify the camera's movement or change in different directions
"""horizontal""vertical""pan""tilt""roll""zoom"camera_control_config_valueoptionalintegerConfig value to control camera's movement or change in different directions
""Range: -10 - 10camera_control_typeoptionalstringPredefined camera movements type
"""simple""down_back""forward_up""right_turn_forward""left_turn_forward"cfg_scaleoptionalnumberCFG scale to control how closely the image matches the prompt (range 0-1)
0.5Range: 0 - 1durationoptionalintegerDuration of the output in seconds
5510modeoptionalstringstd: Standard Mode, generates videos faster and has lower inference costs. pro: Professional Mode, generates videos use longer duration but higher quality video output.
"std""std""pro"negative_promptoptionalstringDescription of unwanted elements
"No buildings, no artificial objects"Response Type
Returns: Video
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out