Kling 2.6 Serverless API
Still images into immersive cinematic videos with synchronized audio.
POST /v2/kling-2.6 · 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 "prompt": "Visual: São Paulo, Brazil – a narrow street packed with vibrant murals in neon greens, reds, and yellows. The atmosphere is electric: street vendors, kids playing football, and local dancers vibing in the background. The city feels loud, alive, and unapologetic. Subject: A Black male rapper in raw streetwear — fitted cap, graphic tee, worn sneakers, simple chain. He stands front and center, locked in with the camera, body moving naturally to the rhythm, commanding the street like it’s his stage. Audio: [Male rapper, high-energy, gritty voice] Rapping over a hard street beat blended with Brazilian percussion: “Painted walls talk loud, yeah, they know my name, Came up from the block where the heat stay flame. City never soft, had to hustle, stay sharp, Turned struggle into fire, now I’m leavin’ my mark. Bass hit heavy, feel the ground when I step, From these streets to the world, yeah, I’m reppin’ respect.” Background: Heavy bass layered with live drum hits, claps, and subtle street noise — bikes passing, distant voices, raw urban texture. Camera: Rapid cuts between tight close-ups of his face and hands, wide shots of the colorful murals, quick flashes of dancers and street life. Handheld movement keeps it gritty and real, ending on a strong close-up as the beat hits.",
11 "negative_prompt": "no noise, no distortion, no clutter",
12 "cfg_scale": 0.8,
13 "duration": "10",
14 "mode": "pro",
15 "aspect_ratio": "16:9",
16 "generate_audio": True,
17}
18job = client.submit_async("kling-2.6", **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.6", **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 "prompt": "Visual: São Paulo, Brazil – a narrow street packed with vibrant murals in neon greens, reds, and yellows. The atmosphere is electric: street vendors, kids playing football, and local dancers vibing in the background. The city feels loud, alive, and unapologetic. Subject: A Black male rapper in raw streetwear — fitted cap, graphic tee, worn sneakers, simple chain. He stands front and center, locked in with the camera, body moving naturally to the rhythm, commanding the street like it’s his stage. Audio: [Male rapper, high-energy, gritty voice] Rapping over a hard street beat blended with Brazilian percussion: “Painted walls talk loud, yeah, they know my name, Came up from the block where the heat stay flame. City never soft, had to hustle, stay sharp, Turned struggle into fire, now I’m leavin’ my mark. Bass hit heavy, feel the ground when I step, From these streets to the world, yeah, I’m reppin’ respect.” Background: Heavy bass layered with live drum hits, claps, and subtle street noise — bikes passing, distant voices, raw urban texture. Camera: Rapid cuts between tight close-ups of his face and hands, wide shots of the colorful murals, quick flashes of dancers and street life. Handheld movement keeps it gritty and real, ending on a strong close-up as the beat hits.",
11 "negative_prompt": "no noise, no distortion, no clutter",
12 "cfg_scale": 0.8,
13 "duration": "10",
14 "mode": "pro",
15 "aspect_ratio": "16:9",
16 "generate_audio": True,
17}
18job = client.submit_async("kling-2.6", **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.6", **payload)API Endpoint
https://api.segmind.com/v1/kling-2.6Parameters
promptrequiredstringGuides the scene. Try 'tranquil forest morning' for nature-themed visuals.
"Visual: São Paulo, Brazil – a narrow street packed with vibrant murals in neon greens, reds, and yellows. The atmosphere is electric: street vendors, kids playing football, and local dancers vibing in the background. The city feels loud, alive, and unapologetic. Subject: A Black male rapper in raw streetwear — fitted cap, graphic tee, worn sneakers, simple chain. He stands front and center, locked in with the camera, body moving naturally to the rhythm, commanding the street like it’s his stage. Audio: [Male rapper, high-energy, gritty voice] Rapping over a hard street beat blended with Brazilian percussion: “Painted walls talk loud, yeah, they know my name, Came up from the block where the heat stay flame. City never soft, had to hustle, stay sharp, Turned struggle into fire, now I’m leavin’ my mark. Bass hit heavy, feel the ground when I step, From these streets to the world, yeah, I’m reppin’ respect.” Background: Heavy bass layered with live drum hits, claps, and subtle street noise — bikes passing, distant voices, raw urban texture. Camera: Rapid cuts between tight close-ups of his face and hands, wide shots of the colorful murals, quick flashes of dancers and street life. Handheld movement keeps it gritty and real, ending on a strong close-up as the beat hits."aspect_ratiooptionalstringSets frame dimensions. Use '16:9' for widescreen.
"16:9""16:9""9:16""1:1"cfg_scaleoptionalnumberAdjusts style strength. Set to 0.8 for vivid details.
0.8Range: 0 - 1durationoptionalintegerDefines video length. Use '10' for longer scenes.
10510generate_audiooptionalbooleanIncludes music. Set to true for engaging audio.
trueimage_urloptionalstring (uri)Link to video background. Use scenic images for dramatic effects.
nullmodeoptionalstringControls output quality. Choose 'pro' for polished outcomes.
"pro""pro"negative_promptoptionalstringRemoves unwanted elements. Use 'no noise' for cleaner visuals.
"no noise, no distortion, no clutter"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.6Submit — 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