Kling AI Text-to-Video
Overview
Generate videos from text prompts using the /v1/videos/text2video endpoint. Supports models v1 through v2.6, standard/professional modes, camera control, negative prompts, and native audio (v2.6+).
Endpoint: POST https://api.klingai.com/v1/videos/text2video
Request Parameters
| Parameter |
Type |
Required |
Description |
model_name |
string |
Yes |
Model version (see model catalog) |
prompt |
string |
Yes |
Video description, max 2500 chars |
negative_prompt |
string |
No |
What to exclude from generation |
duration |
string |
Yes |
"5" or "10" seconds |
aspect_ratio |
string |
No |
"16:9" (default), "9:16", "1:1", etc. |
mode |
string |
No |
"standard" (default) or "professional" |
cfg_scale |
float |
No |
Prompt adherence (0.0-1.0, default 0.5) |
camera_control |
object |
No |
Camera movement config |
callback_url |
string |
No |
Webhook URL for completion notification |
Complete Example — Python
import jwt, time, os, requests
BASE = "https://api.klingai.com/v1"
def get_headers():
ak, sk = os.environ["KLING_ACCESS_KEY"], os.environ["KLING_SECRET_KEY"]
token = jwt.encode(
{"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5},
sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}
)
return {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
# Create text-to-video task
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
"model_name": "kling-v2-6",
"prompt": "Aerial drone shot of a coral reef at golden hour, "
"tropical fish swimming through crystal clear water, "
"sun rays penetrating the surface, cinematic 4K",
"negative_prompt": "blurry, low quality, distorted, watermark",
"duration": "5",
"aspect_ratio": "16:9",
"mode": "professional",
"cfg_scale": 0.5,
})
task = response.json()
task_id = task["data"]["task_id"]
# Poll for completion
while True:
time.sleep(15)
result = requests.get(
f"{BASE}/videos/text2video/{task_id}", headers=get_headers()
).json()
status = result["data"]["task_status"]
if status == "succeed":
video = result["data"]["task_result"]["videos"][0]
print(f"Video URL: {video['url']}")
print(f"Duration: {video['duration']}s")
break
elif status == "failed":
raise RuntimeError(result["data"]["task_status_msg"])
# else: submitted/processing — keep polling
With Camera Control
# Camera movement types: pan, tilt, zoom, roll
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
"model_name": "kling-v2-6",
"prompt": "A medieval castle on a cliff at sunrise, fog in the valley",
"duration": "5",
"mode": "standard",
"camera_control": {
"type": "simple",
"config": {
"horizontal": 5, # pan right (negative = left), range -10 to 10
"vertical": 0, # tilt (negative = down, positive = up)
"zoom": 3, # zoom in (positive) or out (negative)
"roll": 0, # rotation
"pan": 0, # dolly left/right
"tilt": -2, # dolly up/down
}
},
})
Rule: Only one non-zero field in config for type: "simple".
With Native Audio (v2.6 only)
response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
"model_name": "kling-v2-6",
"prompt": "A jazz band performing in a dimly lit club, saxophone solo, "
"audience clapping, warm amber lighting",
"duration": "10",
"mode": "professional",
"motion_has_audio": True, # generates synchronized audio
})
Prompt Engineering Tips
| Technique |
Example |
| Scene + action + style |
"A samurai walking through cherry blossoms, cinematic slow motion" |
| Lighting cues |
"golden hour", "neon-lit", "overcast diffused light" |
| Camera language |
"close-up", "wide establishing shot", "tracking shot" |
| Negative prompt |
"blurry, watermark, text overlay, distorted faces" |
| Material/texture |
"brushed steel", "hand-painted watercolor", "photorealistic" |
Cost Reference
| Duration |
Standard |
Professional |
| 5 seconds |
10 credits |
35 credits |
| 10 seconds |
20 credits |
70 credits |
Error Handling
| Error |
Cause |
Fix |
400 invalid prompt |
Empty or >2500 chars |
Check prompt length |
400 invalid model |
Unsupported model_name |
Use valid model ID from catalog |
402 insufficient credits |
Not enough credits |
Top up account |
task_status: failed |
Content policy violation or complexity |
Simplify prompt, remove restricted content |
Prerequisites
- An approved brief, rights-cleared or synthetic reference material, an authorized workspace and budget, a content-policy review, and a named owner for publication and removal.
Instructions
- Create a sandbox draft from an approved brief; do not include private individuals, protected material, or unverified claims in prompts or uploads.
- Verify the requested duration, style, destination, credit budget, content-policy status, and draft-only setting before submission.
- Review one watermarked canary render for policy, rights, and quality; halt on a policy or attribution concern and delete the draft rather than publishing it.
- Promote only after owner approval and retain a redacted production receipt; remove temporary assets at the approved retention boundary.
Output
Produce a render receipt with brief ID, approved source classification, model/mode, duration, credit estimate, policy and rights-review outcome, draft destination, approver, retention/removal reference, and task ID. Exclude prompt text, identities, and credentials.
Examples
brief=synthetic-product-demo; source=rights-cleared; mode=standard; duration=5s; policy=pass; destination=draft-only; approval=pending; cleanup=24h is a safe canary request.
Resources
1---2name: klingai-text-to-video3description: Generate videos from text prompts with Kling AI. Use when creating videos from descriptions, learning prompt techniques, or building T2V pipelines. Trigger with phrases like 'kling ai text to video', 'klingai prompt', 'generate video from text', 'text2video kling'.4license: MIT5---6# Kling AI Text-to-Video
7
8## Overview
9
10Generate videos from text prompts using the `/v1/videos/text2video` endpoint. Supports models v1 through v2.6, standard/professional modes, camera control, negative prompts, and native audio (v2.6+).
11
12**Endpoint:** `POST https://api.klingai.com/v1/videos/text2video`
13
14## Request Parameters
15
16| Parameter | Type | Required | Description |
17|-----------|------|----------|-------------|
18| `model_name` | string | Yes | Model version (see model catalog) |
19| `prompt` | string | Yes | Video description, max 2500 chars |
20| `negative_prompt` | string | No | What to exclude from generation |
21| `duration` | string | Yes | `"5"` or `"10"` seconds |
22| `aspect_ratio` | string | No | `"16:9"` (default), `"9:16"`, `"1:1"`, etc. |
23| `mode` | string | No | `"standard"` (default) or `"professional"` |
24| `cfg_scale` | float | No | Prompt adherence (0.0-1.0, default 0.5) |
25| `camera_control` | object | No | Camera movement config |
26| `callback_url` | string | No | Webhook URL for completion notification |
27
28## Complete Example — Python
29
30```python
31import jwt, time, os, requests
32
33BASE = "https://api.klingai.com/v1"
34
35def get_headers():
36 ak, sk = os.environ["KLING_ACCESS_KEY"], os.environ["KLING_SECRET_KEY"]
37 token = jwt.encode(
38 {"iss": ak, "exp": int(time.time()) + 1800, "nbf": int(time.time()) - 5},
39 sk, algorithm="HS256", headers={"alg": "HS256", "typ": "JWT"}
40 )
41 return {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
42
43# Create text-to-video task
44response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
45 "model_name": "kling-v2-6",
46 "prompt": "Aerial drone shot of a coral reef at golden hour, "
47 "tropical fish swimming through crystal clear water, "
48 "sun rays penetrating the surface, cinematic 4K",
49 "negative_prompt": "blurry, low quality, distorted, watermark",
50 "duration": "5",
51 "aspect_ratio": "16:9",
52 "mode": "professional",
53 "cfg_scale": 0.5,
54})
55
56task = response.json()
57task_id = task["data"]["task_id"]
58
59# Poll for completion
60while True:
61 time.sleep(15)
62 result = requests.get(
63 f"{BASE}/videos/text2video/{task_id}", headers=get_headers()
64 ).json()
65
66 status = result["data"]["task_status"]
67 if status == "succeed":
68 video = result["data"]["task_result"]["videos"][0]
69 print(f"Video URL: {video['url']}")
70 print(f"Duration: {video['duration']}s")
71 break
72 elif status == "failed":
73 raise RuntimeError(result["data"]["task_status_msg"])
74 # else: submitted/processing — keep polling
75```
76
77## With Camera Control
78
79```python
80# Camera movement types: pan, tilt, zoom, roll
81response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
82 "model_name": "kling-v2-6",
83 "prompt": "A medieval castle on a cliff at sunrise, fog in the valley",
84 "duration": "5",
85 "mode": "standard",
86 "camera_control": {
87 "type": "simple",
88 "config": {
89 "horizontal": 5, # pan right (negative = left), range -10 to 10
90 "vertical": 0, # tilt (negative = down, positive = up)
91 "zoom": 3, # zoom in (positive) or out (negative)
92 "roll": 0, # rotation
93 "pan": 0, # dolly left/right
94 "tilt": -2, # dolly up/down
95 }
96 },
97})
98```
99
100**Rule:** Only one non-zero field in `config` for `type: "simple"`.
101
102## With Native Audio (v2.6 only)
103
104```python
105response = requests.post(f"{BASE}/videos/text2video", headers=get_headers(), json={
106 "model_name": "kling-v2-6",
107 "prompt": "A jazz band performing in a dimly lit club, saxophone solo, "
108 "audience clapping, warm amber lighting",
109 "duration": "10",
110 "mode": "professional",
111 "motion_has_audio": True, # generates synchronized audio
112})
113```
114
115## Prompt Engineering Tips
116
117| Technique | Example |
118|-----------|---------|
119| Scene + action + style | "A samurai walking through cherry blossoms, cinematic slow motion" |
120| Lighting cues | "golden hour", "neon-lit", "overcast diffused light" |
121| Camera language | "close-up", "wide establishing shot", "tracking shot" |
122| Negative prompt | "blurry, watermark, text overlay, distorted faces" |
123| Material/texture | "brushed steel", "hand-painted watercolor", "photorealistic" |
124
125## Cost Reference
126
127| Duration | Standard | Professional |
128|----------|----------|-------------|
129| 5 seconds | 10 credits | 35 credits |
130| 10 seconds | 20 credits | 70 credits |
131
132## Error Handling
133
134| Error | Cause | Fix |
135|-------|-------|-----|
136| `400` invalid prompt | Empty or >2500 chars | Check prompt length |
137| `400` invalid model | Unsupported `model_name` | Use valid model ID from catalog |
138| `402` insufficient credits | Not enough credits | Top up account |
139| `task_status: failed` | Content policy violation or complexity | Simplify prompt, remove restricted content |
140
141## Prerequisites
142
143- An approved brief, rights-cleared or synthetic reference material, an authorized workspace and budget, a content-policy review, and a named owner for publication and removal.
144
145## Instructions
146
1471. Create a sandbox draft from an approved brief; do not include private individuals, protected material, or unverified claims in prompts or uploads.
1482. Verify the requested duration, style, destination, credit budget, content-policy status, and draft-only setting before submission.
1493. Review one watermarked canary render for policy, rights, and quality; halt on a policy or attribution concern and delete the draft rather than publishing it.
1504. Promote only after owner approval and retain a redacted production receipt; remove temporary assets at the approved retention boundary.
151
152## Output
153
154Produce a render receipt with brief ID, approved source classification, model/mode, duration, credit estimate, policy and rights-review outcome, draft destination, approver, retention/removal reference, and task ID. Exclude prompt text, identities, and credentials.
155
156## Examples
157
158`brief=synthetic-product-demo; source=rights-cleared; mode=standard; duration=5s; policy=pass; destination=draft-only; approval=pending; cleanup=24h` is a safe canary request.
159
160## Resources
161
162- [Text-to-Video API](https://app.klingai.com/global/dev/document-api/apiReference/model/textToVideo)
163- [Camera Control Guide](https://app.klingai.com/global/quickstart/ai-camera-control-guide)
164- [Content Guidelines](https://app.klingai.com/global/dev/document-api/protocols/paidServiceProtocol)