Kling 4.0 API

Send a prompt from your own server, get a task ID back at once, and poll until the MP4 is ready. Kling 4.0 is the default model, and every call spends the same credits as the Kling4 web app.

Quick start

Every call goes to https://kling4.video/v1 with your key in the Authorization header as a Bearer token. Bodies are JSON, and the create call refuses any other Content-Type. Rendering is asynchronous: you never wait on the create call for the video.

1. Get an API key

Sign in, open Settings → API keys and create a key with a name of up to 32 characters. The secret starts with sk_sd_ and is displayed once, so store it straight away in your server environment (the examples read KLING4_API_KEY). Keys have no expiry date and stop working only when you revoke them on that page. Call the API from a backend, never from a browser or app bundle.

2. Create a task and poll it

This asks for 8 seconds of vertical 720p video. A 200 response only means the task was accepted and its credits are on hold; the status reads pending while it waits, processing while it renders, then completed or failed. Checking every 5 to 10 seconds is enough.

# Create a Kling 4.0 task
curl https://kling4.video/v1/videos/generations \
  -H "Authorization: Bearer $KLING4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kling_v4",
    "prompt": "A street cellist plays under a railway bridge at dawn, pigeons lift off as a train rumbles overhead, slow push-in",
    "duration": 8,
    "quality": "720p",
    "aspect_ratio": "9:16"
  }'
# Response: {"task_id": "...", "status": "pending", "created_at": "..."}

# Poll it until status is "completed" or "failed"
curl https://kling4.video/v1/tasks/$TASK_ID \
  -H "Authorization: Bearer $KLING4_API_KEY"

Python

With requests, polling every 8 seconds:

import os
import time

import requests

BASE = "https://kling4.video/v1"
AUTH = {"Authorization": f"Bearer {os.environ['KLING4_API_KEY']}"}

job = requests.post(
    f"{BASE}/videos/generations",
    headers=AUTH,
    json={
        "model": "kling_v4",
        "prompt": "A street cellist plays under a railway bridge at dawn, pigeons lift off as a train rumbles overhead, slow push-in",
        "duration": 8,
        "quality": "720p",
        "aspect_ratio": "9:16",
    },
    timeout=30,
)
job.raise_for_status()
task_id = job.json()["task_id"]

while True:
    time.sleep(8)
    res = requests.get(f"{BASE}/tasks/{task_id}", headers=AUTH, timeout=30)
    if res.status_code == 429:
        continue
    res.raise_for_status()
    task = res.json()
    if task["status"] == "completed":
        print(task["output"]["video_url"], task["credits_used"])
        break
    if task["status"] == "failed":
        raise RuntimeError(task["error"])

Node.js

The same flow with fetch:

// Node 18+ (built-in fetch), saved as an ES module (.mjs)
const BASE = 'https://kling4.video/v1';
const auth = { Authorization: `Bearer ${process.env.KLING4_API_KEY}` };
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

const created = await fetch(`${BASE}/videos/generations`, {
  method: 'POST',
  headers: { ...auth, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    model: 'kling_v4',
    prompt: 'A street cellist plays under a railway bridge at dawn, pigeons lift off as a train rumbles overhead, slow push-in',
    duration: 8,
    quality: '720p',
    aspect_ratio: '9:16',
  }),
});
if (!created.ok) throw new Error(`${created.status} ${await created.text()}`);
const { task_id } = await created.json();

while (true) {
  await sleep(8000);
  const res = await fetch(`${BASE}/tasks/${task_id}`, { headers: auth });
  if (res.status === 429) continue;
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  const task = await res.json();
  if (task.status === 'completed') {
    console.log(task.output.video_url, task.credits_used);
    break;
  }
  if (task.status === 'failed') throw new Error(task.error);
}

A completed task carries output.video_url, a link to the MP4 that Kling4 stores, plus output.duration, output.quality and credits_used. A failed one has output set to null and a readable reason in error.

Endpoints

Three endpoints, all under https://kling4.video and all authenticated the same way. A failed call returns an error object with code, message, param and request_id; branch on code, and quote the request ID (also sent as an X-Request-Id header) when you contact support.
Kling4 API endpoints
—Method and pathWhat you get back
Create a video taskPOST /v1/videos/generationstask_id, status "pending" and created_at
Read a taskGET /v1/tasks/{task_id}status, model, output (video_url, duration, quality), credits_used, error, created_at, completed_at
Check your balanceGET /v1/creditstotal, reserved (held by running videos) and available credits

Request fields and Kling models

The create call takes these fields and nothing else; an unknown field is rejected with 422 and its name in param.

FieldWhat it takes
modelRequired. One of the four model IDs in the next table.
promptUp to 2,500 characters. Required on every model except kling_v3_image_to_video. In kling_v4 reference runs, name images by position: @Image 1, @Image 2.
durationWhole seconds: 3–30 on kling_v4, 4–15 on the Kling 3.0 and O3 IDs. Left out, the clip is 5 seconds.
quality720p (default) or 1080p; 4k on the two Kling 3.0 IDs only.
aspect_ratio16:9 (default), 9:16 or 1:1, and 21:9 on kling_v4. Runs that start from an image take its shape.
image_urlsHTTPS links. On kling_v4 one image is the first frame, two are first and last frame, and three to ten are references.
reference_modekling_v4 only: true treats one or two images as references instead of frames.
generate_audioKling 3.0 and O3 only, on unless false. Kling 4.0 always renders sound and rejects the field.
video_urlsOne HTTPS clip, on kling_o3_text_to_video only.

Only these Kling model IDs are accepted by the API:

Model IDModelLengthResolutionInput
kling_v4Kling 4.03–30 s720p, 1080pText, or 1–10 images
kling_o3_text_to_videoKling O34–15 s (10 with a clip)720p, 1080pText, up to 2 images, 1 video
kling_v3_text_to_videoKling 3.04–15 s720p, 1080p, 4KText
kling_v3_image_to_videoKling 3.04–15 s720p, 1080p, 4K1 or 2 images (first and last frame)

Kling 4.0 API pricing

There is no API plan and no fee per request. A task spends credits from the balance you already use in the web app, at the same per-second rates: 3 credits a second for Kling 4.0 at 720p and 5 at 1080p. On the Creator pack that is about $0.40 and $0.67 per second.

The quick-start clip (8 s at 720p) costs 24 credits, or 17 on Pro, because plan discounts apply to API tasks too: 10% on Lite, 30% on Pro and 40% on Premium. Credits are held when the task is accepted, deducted when it completes and released if it fails, and credits_used on the task shows the exact figure. If the available balance is short, the create call answers 402 insufficient_credits and names the amount needed.

Kling 4.0 needs a Lite, Pro or Premium plan or a Creator, Studio, Max or Agency pack; without one the create call returns 403 plan_upgrade_required. Pack prices and the cost of each clip length are on the pricing page.

Credits per second of output, before plan discounts.
Model ID720p1080p4K
kling_v435—
kling_o3_text_to_video2.54—
kling_v3_text_to_video2.5410
kling_v3_image_to_video2.5410

Credits per second of output, before plan discounts.

Rate limits

Four limits apply, and each one answers HTTP 429:

  • Per key: 120 requests in each 60-second window, across all three endpoints. A window opens with the first request and closes 60 seconds later, however steady the traffic, so a script polling every 8 seconds never reaches the cap. Past it, calls get rate_limit_exceeded with a Retry-After header counting the seconds left in the window.
  • Per IP address, before the key is checked: create calls at least 1 s apart and no more than 20 a minute; reads of one task URL or of /v1/credits at least 0.1 s apart and no more than 180 a minute. These replies carry a Retry-After header and a shorter body, {"error": "too_many_requests", "message": "..."}, without a request ID.
  • Per account, videos rendering at the same time: 1 on Free, Lite or packs only, 4 on Pro and 8 on Premium. Videos started in the web app count. One more create returns concurrent_generation_limit_reached.
  • The per-key count is shared by every server. The IP limits are counted on each server instance, so treat them as a ceiling to stay under, not a quota to plan around.

Honor Retry-After when it is sent, otherwise back off with some jitter. Poll each task every 5 to 10 seconds, stop as soon as it finishes, and let long batch jobs wait out Retry-After instead of failing on it.

What is web-app only

  • Motion control: kling_v3_motion_control and kling_v2_6_motion_control return 422 invalid_request with "This model is available in the web app only."
  • Reference clips on Kling 4.0: video_urls on kling_v4 returns 422 with "This model does not accept video_urls through the API." Both are priced on the length of the reference clip, and over the API that clip would be fetched from your host twice (once to measure, once by the model), so until API clips are copied to Kling4's own storage first, use the web app for these.
  • kling_v4 renders at 720p or 1080p. 4K, middle keyframes and Kling 4.0 Flash are not offered on Kling4 at all.
  • There are no webhooks and no idempotency key. Poll for results, and save each task_id: resending a create that already went through starts and bills a second video.
  • Media goes in as public HTTPS links, not uploads. Links with credentials or private and local addresses are refused with param media_url.

Tasks you start in the web app, motion control included, can still be read with GET /v1/tasks/{task_id}.

Reference and next steps

The API documentation has every field, response and error code in detail; it is written for developers and kept out of search. To test a prompt before wiring it into code, try Kling 4.0 in the browser, where one 5-second clip needs no account.

Kling 4.0 API questions

Is there a Kling 4.0 API?

Yes. Kling4 runs a public REST API at https://kling4.video/v1 with three endpoints: create a video task, read a task, and check your credit balance. Send model kling_v4 for Kling 4.0, or one of the Kling 3.0 and Kling O3 IDs. Kling4 is independent of Kuaishou and Kling AI; the renders go through the official Kling API.

What are the rate limits?

Each key gets 120 requests per 60-second window across all endpoints, and the count starts over when the window ends. Per IP address, create calls are capped at 20 a minute, at least one second apart. Videos rendering at once depend on the plan: one on Free, Lite or packs only, four on Pro and eight on Premium. Going over any limit returns HTTP 429.

How is API usage billed?

In Kling4 credits, taken from the same balance as the web app, with no separate API fee. Kling 4.0 costs 3 credits a second at 720p and 5 at 1080p, less your plan discount. Credits are held when a task is accepted, charged when it completes and released if it fails, and credits_used on the task shows the exact amount.