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.

PlaygroundAPI
Pricing
~135.16s
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)

API Endpoint

POSThttps://api.segmind.com/v1/kling-2.1

Parameters

imagerequired
string (uri)

Provide an image to be animated. Use clear, high-quality images for best results.

Default: "https://segmind-resources.s3.amazonaws.com/input/e1fcf474-2790-4e1a-b094-ae0b20a18ab8-428e317b-d7c2-48fb-a001-ed0820fb04be.jpg"
aspect_ratiooptional
string

Select output aspect ratio. '16:9' is best for widescreens, '1:1' for social media.

Default: "16:9"
Allowed values :
"16:9""9:16""1:1"
cfg_scaleoptional
number

Controls animation adherence to the prompt. Lower for more freedom, higher for precise adherence.

Default: 0.7Range: 0 - 1
durationoptional
integer

Set animation duration. Choose '5' for short previews, '10' for detailed views.

Default: 5
Allowed values :
510
image_tailoptional
string (uri)

Last frame of the video (pro mode is required when this parameter is set)

modeoptional
string

Choose animation quality mode. 'Pro' for balanced quality, 'Master' for quality focus.

Default: "pro"
Allowed values :
"std""pro""master"
negative_promptoptional
string

Specify unwanted effects. List distractions like sudden flashes or fast zooms to avoid them.

Default: "No jittery motion, avoid rapid scene changes."
promptoptional
string

Describe the desired animation effect. Use creative, vivid descriptions for dynamic animations.

Default: "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. 1
    POST /v2/kling-2.1

    Submit — returns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Poll — until COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Result — final response body

Status states

QUEUED— Accepted, waiting for a worker
PROCESSING— Running on a worker
COMPLETED— Done — result body is ready
FAILED— Errored (incl. content/RAI blocks)
  • 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.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out