Kling 4.0 API
Call Kling video models, with Kling 4.0 as the default, from your own backend with the Kling4 API. Send a prompt, poll the task, download the MP4, and pay per clip in credits.
The Kling4 API puts the Kling model family, from Kling 2.6 Motion Control up to Kling 4.0, behind three HTTP endpoints. You post a JSON body with a prompt and, if you like, links to images or videos. The API hands back a task ID at once, renders in the background, and gives you a stored MP4 when it is done. Every endpoint sits under https://kling4.video/v1 and authenticates with a Bearer key.
Kling4 is an independent service and is not affiliated with Kuaishou or Kling AI. Renders run through the official Kling API.
- 01POST
/v1/videos/generations - 02READ
task_id - 03GET
/v1/tasks/{task_id} - 04DONE
completed + video_url
Pricing: what a clip costs
There is no separate API subscription and no per-call fee. API tasks spend the same credits as the kling4.video web app, from the same balance, so any Kling4 plan or credit pack works for the API.
The price of one clip comes from a few inputs:
- Model. Every model has its own per-second credit rate.
- Resolution. 1080p costs more per second than 720p.
- Length. The rate is multiplied by the output duration. If you leave out
duration, the task is priced as 5 seconds.
You never have to work the number out yourself. As soon as a task is accepted, GET /v1/tasks/{task_id} reports its exact price in credits_used. Those credits are put on hold while the video renders, deducted when it completes, and released if it fails. If your balance is too low, the create call returns 402 and the message says how many credits the request needed. Plan and credit pack prices are on the pricing page.
Step 1: get a key
In Settings → API keys, create a key. The secret appears only once, so copy it into your server's secret store before you close the dialog. Authentication covers storage, rotation and limits.
Step 2: submit a video
cURL
curl https://kling4.video/v1/videos/generations \
-H "Authorization: Bearer sk_sd_example" \
-H "Content-Type: application/json" \
-d '{
"model": "kling_v4",
"prompt": "Morning fog lifting off a mountain lake, slow aerial glide over pine trees",
"duration": 5,
"quality": "720p",
"aspect_ratio": "16:9"
}'{
"task_id": "Vq3x8LmZ2tR9bK_wP0sYd",
"status": "pending",
"created_at": "2026-11-03T09:12:04.000Z"
}JavaScript
const res = await fetch('https://kling4.video/v1/videos/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.KLING4_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'kling_v4',
prompt: 'Morning fog lifting off a mountain lake, slow aerial glide',
duration: 5,
quality: '720p',
}),
});
if (!res.ok) throw new Error(`Kling4 API ${res.status}: ${await res.text()}`);
const { task_id } = await res.json();Python
import os
import requests
res = requests.post(
"https://kling4.video/v1/videos/generations",
headers={"Authorization": f"Bearer {os.environ['KLING4_API_KEY']}"},
json={
"model": "kling_v4",
"prompt": "Morning fog lifting off a mountain lake, slow aerial glide",
"duration": 5,
"quality": "720p",
},
timeout=30,
)
res.raise_for_status()
task_id = res.json()["task_id"]A 200 only means the task was accepted and its credits are on hold. The video is not ready yet, so keep the task_id. Treat it as an opaque string: store it as is and do not parse it.
Step 3: poll until it finishes
Call GET /v1/tasks/{task_id}. A new task reads pending while it is queued, processing while the video renders and is saved, and ends as completed or failed. Polling every 5 to 10 seconds is plenty; stretch the gap for long or high-resolution clips.
curl https://kling4.video/v1/tasks/Vq3x8LmZ2tR9bK_wP0sYd \
-H "Authorization: Bearer sk_sd_example"{
"task_id": "Vq3x8LmZ2tR9bK_wP0sYd",
"status": "completed",
"model": "kling_v4",
"output": {
"video_url": "https://<media-host>/videos/video_Vq3x8LmZ2tR9bK_wP0sYd_1792487609000.mp4",
"duration": 5,
"quality": "720p"
},
"credits_used": 15,
"error": null,
"created_at": "2026-11-03T09:12:04.000Z",
"completed_at": "2026-11-03T09:13:31.000Z"
}output.video_url points at a copy Kling4 keeps in its own storage, so the link stays valid after the task is over. If the status is failed, output is null, error explains why in plain words, and the credits on hold go back to your available balance.
Step 4: check your balance
curl https://kling4.video/v1/credits \
-H "Authorization: Bearer sk_sd_example"{ "total": 1200, "reserved": 15, "available": 1185 }reserved covers every video still in progress on your account, including ones started in the kling4.video web app, so available is what your next API task can really spend.
Where to go next
- Models and inputs: model IDs, input limits, durations and resolutions.
- Errors and retries: every status and error code, and which ones are safe to retry.
- The API reference pages describe each field of the three endpoints.