Kling 2.1 AI Video Generator API
Kling 2.1 offers hyper-realistic video generation with improved motion, sharper 1080p visuals, and instant restyling capabilities. Its cost-effective pricing and faster rendering times make it a game-changer for creators seeking cinematic-quality AI videos.
POST /v2/kling-2.1 · submit + poll 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3from segmind import SegmindClient, InferenceFailed, InferenceTimeout
4
5# Async (v2) — recommended for long-running / video models.
6# run() blocks up to 600s; submit_async + job.wait(timeout=...) sets a longer
7# deadline and keeps the request_id so you can re-poll later.
8client = SegmindClient() # reads SEGMIND_API_KEY
9payload = {
10 "image": "https://segmind-resources.s3.amazonaws.com/input/e1fcf474-2790-4e1a-b094-ae0b20a18ab8-428e317b-d7c2-48fb-a001-ed0820fb04be.jpg",
11 "prompt": "Front View Shot of model in casual wear. [Push in] [Static shot] Subtle shoulder rotation, confident smile, hands in pockets, slight weight shift.",
12 "negative_prompt": "No jittery motion, avoid rapid scene changes.",
13 "cfg_scale": 0.7,
14 "mode": "pro",
15 "aspect_ratio": "16:9",
16 "duration": 5,
17}
18job = client.submit_async("kling-2.1", **payload)
19print(job.request_id) # available immediately
20try:
21 result = job.wait(timeout=900, interval=2.0)
22 print(result["status"]) # COMPLETED
23 print(result.get("output")) # model output (e.g. video URL)
24except InferenceTimeout as e:
25 print("still running:", e.request_id) # re-poll later with this id
26except InferenceFailed as e:
27 print("failed:", e.detail)
28
29# Fast models (<=600s) can use the one-liner instead:
30# result = segmind.run("kling-2.1", **payload) 1# pip install "segmind>=1.1.0"
2# export SEGMIND_API_KEY="YOUR_API_KEY"
3from segmind import SegmindClient, InferenceFailed, InferenceTimeout
4
5# Async (v2) — recommended for long-running / video models.
6# run() blocks up to 600s; submit_async + job.wait(timeout=...) sets a longer
7# deadline and keeps the request_id so you can re-poll later.
8client = SegmindClient() # reads SEGMIND_API_KEY
9payload = {
10 "image": "https://segmind-resources.s3.amazonaws.com/input/e1fcf474-2790-4e1a-b094-ae0b20a18ab8-428e317b-d7c2-48fb-a001-ed0820fb04be.jpg",
11 "prompt": "Front View Shot of model in casual wear. [Push in] [Static shot] Subtle shoulder rotation, confident smile, hands in pockets, slight weight shift.",
12 "negative_prompt": "No jittery motion, avoid rapid scene changes.",
13 "cfg_scale": 0.7,
14 "mode": "pro",
15 "aspect_ratio": "16:9",
16 "duration": 5,
17}
18job = client.submit_async("kling-2.1", **payload)
19print(job.request_id) # available immediately
20try:
21 result = job.wait(timeout=900, interval=2.0)
22 print(result["status"]) # COMPLETED
23 print(result.get("output")) # model output (e.g. video URL)
24except InferenceTimeout as e:
25 print("still running:", e.request_id) # re-poll later with this id
26except InferenceFailed as e:
27 print("failed:", e.detail)
28
29# Fast models (<=600s) can use the one-liner instead:
30# result = segmind.run("kling-2.1", **payload)API Endpoint
https://api.segmind.com/v1/kling-2.1Parameters
imagerequiredstring (uri)Provide an image to be animated. Use clear, high-quality images for best results.
"https://segmind-resources.s3.amazonaws.com/input/e1fcf474-2790-4e1a-b094-ae0b20a18ab8-428e317b-d7c2-48fb-a001-ed0820fb04be.jpg"aspect_ratiooptionalstringSelect output aspect ratio. '16:9' is best for widescreens, '1:1' for social media.
"16:9""16:9""9:16""1:1"cfg_scaleoptionalnumberControls animation adherence to the prompt. Lower for more freedom, higher for precise adherence.
0.7Range: 0 - 1durationoptionalintegerSet animation duration. Choose '5' for short previews, '10' for detailed views.
5510image_tailoptionalstring (uri)Last frame of the video (pro mode is required when this parameter is set)
modeoptionalstringChoose animation quality mode. 'Pro' for balanced quality, 'Master' for quality focus.
"pro""std""pro""master"negative_promptoptionalstringSpecify unwanted effects. List distractions like sudden flashes or fast zooms to avoid them.
"No jittery motion, avoid rapid scene changes."promptoptionalstringDescribe the desired animation effect. Use creative, vivid descriptions for dynamic animations.
"Front View Shot of model in casual wear. [Push in] [Static shot] Subtle shoulder rotation, confident smile, hands in pockets, slight weight shift."Response Type
Returns: Video
Asynchronous requests (v2)
Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.
- 1
POST /v2/kling-2.1Submit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- A FAILED request is served as HTTP 422 — the body still carries the error detail.
- An unknown or expired request_id returns HTTP 404.
- Results are retained for 1 hour, then expire.
- Content / RAI blocks surface as FAILED, not a separate state.
- Track completion by polling the status endpoint.
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