Kling AI Content Policy
Overview
Kling AI enforces content policies server-side. Tasks with policy-violating prompts return task_status: "failed" with a content policy message. This skill covers pre-submission filtering to avoid wasted credits and API calls.
Restricted Content Categories
Kling AI prohibits prompts that generate:
| Category |
Examples |
| Violence/gore |
Graphic injuries, torture, weapons used violently |
| Adult/sexual |
Explicit nudity, sexual acts, suggestive content |
| Hate/discrimination |
Slurs, targeted harassment, supremacist imagery |
| Illegal activity |
Drug manufacturing, terrorism, fraud instructions |
| Real people |
Deepfakes of identifiable individuals without consent |
| Copyrighted characters |
Trademarked characters (Mickey Mouse, Spider-Man) |
| Misinformation |
Fake news, fabricated events presented as real |
| Self-harm |
Suicide, eating disorders, self-injury instructions |
Pre-Submission Prompt Filter
import re
class PromptFilter:
"""Filter prompts before sending to Kling AI to save credits."""
BLOCKED_PATTERNS = [
r"\b(nude|naked|explicit|nsfw|porn)\b",
r"\b(gore|dismember|torture|mutilat)\b",
r"\b(bomb|terroris|weapon|firearm)\b",
r"\b(suicide|self.harm|kill.yourself)\b",
r"\b(deepfake|impersonat)\b",
]
BLOCKED_TERMS = {
"blood splatter", "graphic violence", "child abuse",
"drug manufacturing", "hate speech",
}
def __init__(self):
self._patterns = [re.compile(p, re.IGNORECASE) for p in self.BLOCKED_PATTERNS]
def check(self, prompt: str) -> tuple[bool, str]:
"""Returns (is_safe, reason)."""
lower = prompt.lower()
for term in self.BLOCKED_TERMS:
if term in lower:
return False, f"Blocked term: '{term}'"
for pattern in self._patterns:
match = pattern.search(prompt)
if match:
return False, f"Blocked pattern: '{match.group()}'"
if len(prompt) > 2500:
return False, "Prompt exceeds 2500 character limit"
if len(prompt.strip()) < 5:
return False, "Prompt too short"
return True, "OK"
def sanitize(self, prompt: str) -> str:
"""Remove problematic terms and return cleaned prompt."""
for pattern in self._patterns:
prompt = pattern.sub("[removed]", prompt)
return prompt.strip()
Safe Negative Prompts
Always include safety-related negative prompts:
DEFAULT_NEGATIVE_PROMPT = (
"violence, gore, blood, nudity, sexual content, "
"weapons, drugs, hate symbols, distorted faces, "
"watermark, text overlay, low quality, blurry"
)
def safe_request(prompt: str, negative_prompt: str = ""):
"""Build request with safety defaults."""
combined_negative = f"{DEFAULT_NEGATIVE_PROMPT}, {negative_prompt}".strip(", ")
return {
"model_name": "kling-v2-master",
"prompt": prompt,
"negative_prompt": combined_negative,
"duration": "5",
"mode": "standard",
}
Integration with Client
class SafeKlingClient:
"""Kling client with pre-submission content filtering."""
def __init__(self, base_client):
self.client = base_client
self.filter = PromptFilter()
def text_to_video(self, prompt: str, **kwargs):
is_safe, reason = self.filter.check(prompt)
if not is_safe:
raise ValueError(f"Content policy violation: {reason}")
# Add safety negative prompt
kwargs.setdefault("negative_prompt", "")
kwargs["negative_prompt"] = (
f"{DEFAULT_NEGATIVE_PROMPT}, {kwargs['negative_prompt']}".strip(", ")
)
return self.client.text_to_video(prompt, **kwargs)
Handling Server-Side Rejections
def handle_policy_rejection(task_id: str, result: dict):
"""Handle content policy rejections gracefully."""
status_msg = result["data"].get("task_status_msg", "")
if "content policy" in status_msg.lower() or "policy violation" in status_msg.lower():
return {
"error": "content_policy_violation",
"message": "Your prompt was rejected by Kling AI's content policy. "
"Please revise to remove restricted content.",
"task_id": task_id,
"credits_consumed": False, # policy rejections typically don't consume credits
}
return {"error": "generation_failed", "message": status_msg, "task_id": task_id}
User-Facing Guidelines
When building apps with user-submitted prompts:
- Filter before API call -- saves credits on obvious violations
- Explain rejections clearly -- tell users what to change
- Log violations -- track patterns for filter improvement
- Rate limit prompt submissions -- prevent abuse
- Review flagged content -- human review for edge cases
Prerequisites
- A versioned policy configuration, an owner for escalation, a review queue, and a documented retention/deletion schedule.
- A synthetic or rights-cleared fixture set for tests. Likeness, voice, and other identifiable-person inputs require documented consent; do not rely on a prompt filter as proof of rights.
- A bounded credit budget and a private, watermarked draft destination. Public distribution requires a separate approval record after policy and quality checks.
Instructions
- Normalize the prompt and provenance metadata, then run the local filter before creating a task. Preserve only a redacted reason code for rejected content.
- Check violence, sexual content, hate, illegal activity, self-harm, misinformation, likeness/deepfake, and copyrighted-character risk. Route ambiguous cases to human review rather than trying to evade the policy with sanitization.
- Confirm that every image, mask, tail frame, and reference asset is synthetic or rights-cleared and that the requested destination and audience are approved.
- Submit only a short, watermarked sandbox canary within the credit budget. Keep it private until the policy result, visual review, consent record, and owner approval are complete.
- If the provider rejects the task or a reviewer withdraws approval, do not retry the same request. Quarantine and remove staged media, revoke temporary links, and restore the previous approved version.
- Retain a redacted receipt with policy version, reason code, opaque task digest, approval state, budget state, retention deadline, and rollback reference; exclude prompts, images, identities, and credentials.
Output
Return one of approved_for_draft, needs_human_review, or blocked, together with an opaque request digest, policy version, reason codes, rights/provenance result, canary state, budget result, and retention/rollback instructions. A blocked result must not create a public artifact or expose the submitted content in logs.
Error Handling
Reject locally when a known restricted pattern, missing consent, unknown
provenance, disallowed destination, or budget breach is detected. Treat provider
policy failures as final for that request and report a user-safe revision hint; do
not claim that sanitization makes an unsafe request permissible. For classifier
outages or ambiguous results, fail closed into human review. Quarantine any output
that later receives a complaint, remove its distribution links, preserve only the
redacted audit receipt, and record the rollback owner.
Examples
An internal canary decision can be recorded as:
fixture=synthetic-product-v4; rights=cleared; likeness=none;
policy=pass-v3; destination=staging-private; canary=watermarked;
budget=within-limit; approval=pending; decision=approved_for_draft
An identifiable-person image without a consent record must instead return blocked and create no generation task.
Resources
1---2name: klingai-content-policy3description: Implement content policy compliance for Kling AI prompts and outputs. Use when filtering user prompts or handling moderation. Trigger with phrases like 'klingai content policy', 'kling ai moderation', 'safe video generation', 'klingai content filter'.4license: MIT5---6# Kling AI Content Policy
7
8## Overview
9
10Kling AI enforces content policies server-side. Tasks with policy-violating prompts return `task_status: "failed"` with a content policy message. This skill covers pre-submission filtering to avoid wasted credits and API calls.
11
12## Restricted Content Categories
13
14Kling AI prohibits prompts that generate:
15
16| Category | Examples |
17|----------|---------|
18| Violence/gore | Graphic injuries, torture, weapons used violently |
19| Adult/sexual | Explicit nudity, sexual acts, suggestive content |
20| Hate/discrimination | Slurs, targeted harassment, supremacist imagery |
21| Illegal activity | Drug manufacturing, terrorism, fraud instructions |
22| Real people | Deepfakes of identifiable individuals without consent |
23| Copyrighted characters | Trademarked characters (Mickey Mouse, Spider-Man) |
24| Misinformation | Fake news, fabricated events presented as real |
25| Self-harm | Suicide, eating disorders, self-injury instructions |
26
27## Pre-Submission Prompt Filter
28
29```python
30import re
31
32class PromptFilter:
33 """Filter prompts before sending to Kling AI to save credits."""
34
35 BLOCKED_PATTERNS = [
36 r"\b(nude|naked|explicit|nsfw|porn)\b",
37 r"\b(gore|dismember|torture|mutilat)\b",
38 r"\b(bomb|terroris|weapon|firearm)\b",
39 r"\b(suicide|self.harm|kill.yourself)\b",
40 r"\b(deepfake|impersonat)\b",
41 ]
42
43 BLOCKED_TERMS = {
44 "blood splatter", "graphic violence", "child abuse",
45 "drug manufacturing", "hate speech",
46 }
47
48 def __init__(self):
49 self._patterns = [re.compile(p, re.IGNORECASE) for p in self.BLOCKED_PATTERNS]
50
51 def check(self, prompt: str) -> tuple[bool, str]:
52 """Returns (is_safe, reason)."""
53 lower = prompt.lower()
54
55 for term in self.BLOCKED_TERMS:
56 if term in lower:
57 return False, f"Blocked term: '{term}'"
58
59 for pattern in self._patterns:
60 match = pattern.search(prompt)
61 if match:
62 return False, f"Blocked pattern: '{match.group()}'"
63
64 if len(prompt) > 2500:
65 return False, "Prompt exceeds 2500 character limit"
66
67 if len(prompt.strip()) < 5:
68 return False, "Prompt too short"
69
70 return True, "OK"
71
72 def sanitize(self, prompt: str) -> str:
73 """Remove problematic terms and return cleaned prompt."""
74 for pattern in self._patterns:
75 prompt = pattern.sub("[removed]", prompt)
76 return prompt.strip()
77```
78
79## Safe Negative Prompts
80
81Always include safety-related negative prompts:
82
83```python
84DEFAULT_NEGATIVE_PROMPT = (
85 "violence, gore, blood, nudity, sexual content, "
86 "weapons, drugs, hate symbols, distorted faces, "
87 "watermark, text overlay, low quality, blurry"
88)
89
90def safe_request(prompt: str, negative_prompt: str = ""):
91 """Build request with safety defaults."""
92 combined_negative = f"{DEFAULT_NEGATIVE_PROMPT}, {negative_prompt}".strip(", ")
93 return {
94 "model_name": "kling-v2-master",
95 "prompt": prompt,
96 "negative_prompt": combined_negative,
97 "duration": "5",
98 "mode": "standard",
99 }
100```
101
102## Integration with Client
103
104```python
105class SafeKlingClient:
106 """Kling client with pre-submission content filtering."""
107
108 def __init__(self, base_client):
109 self.client = base_client
110 self.filter = PromptFilter()
111
112 def text_to_video(self, prompt: str, **kwargs):
113 is_safe, reason = self.filter.check(prompt)
114 if not is_safe:
115 raise ValueError(f"Content policy violation: {reason}")
116
117 # Add safety negative prompt
118 kwargs.setdefault("negative_prompt", "")
119 kwargs["negative_prompt"] = (
120 f"{DEFAULT_NEGATIVE_PROMPT}, {kwargs['negative_prompt']}".strip(", ")
121 )
122
123 return self.client.text_to_video(prompt, **kwargs)
124```
125
126## Handling Server-Side Rejections
127
128```python
129def handle_policy_rejection(task_id: str, result: dict):
130 """Handle content policy rejections gracefully."""
131 status_msg = result["data"].get("task_status_msg", "")
132
133 if "content policy" in status_msg.lower() or "policy violation" in status_msg.lower():
134 return {
135 "error": "content_policy_violation",
136 "message": "Your prompt was rejected by Kling AI's content policy. "
137 "Please revise to remove restricted content.",
138 "task_id": task_id,
139 "credits_consumed": False, # policy rejections typically don't consume credits
140 }
141 return {"error": "generation_failed", "message": status_msg, "task_id": task_id}
142```
143
144## User-Facing Guidelines
145
146When building apps with user-submitted prompts:
147
1481. **Filter before API call** -- saves credits on obvious violations
1492. **Explain rejections clearly** -- tell users what to change
1503. **Log violations** -- track patterns for filter improvement
1514. **Rate limit prompt submissions** -- prevent abuse
1525. **Review flagged content** -- human review for edge cases
153
154## Prerequisites
155
156- A versioned policy configuration, an owner for escalation, a review queue, and a documented retention/deletion schedule.
157- A synthetic or rights-cleared fixture set for tests. Likeness, voice, and other identifiable-person inputs require documented consent; do not rely on a prompt filter as proof of rights.
158- A bounded credit budget and a private, watermarked draft destination. Public distribution requires a separate approval record after policy and quality checks.
159
160## Instructions
161
1621. Normalize the prompt and provenance metadata, then run the local filter before creating a task. Preserve only a redacted reason code for rejected content.
1632. Check violence, sexual content, hate, illegal activity, self-harm, misinformation, likeness/deepfake, and copyrighted-character risk. Route ambiguous cases to human review rather than trying to evade the policy with sanitization.
1643. Confirm that every image, mask, tail frame, and reference asset is synthetic or rights-cleared and that the requested destination and audience are approved.
1654. Submit only a short, watermarked sandbox canary within the credit budget. Keep it private until the policy result, visual review, consent record, and owner approval are complete.
1665. If the provider rejects the task or a reviewer withdraws approval, do not retry the same request. Quarantine and remove staged media, revoke temporary links, and restore the previous approved version.
1676. Retain a redacted receipt with policy version, reason code, opaque task digest, approval state, budget state, retention deadline, and rollback reference; exclude prompts, images, identities, and credentials.
168
169## Output
170
171Return one of `approved_for_draft`, `needs_human_review`, or `blocked`, together with an opaque request digest, policy version, reason codes, rights/provenance result, canary state, budget result, and retention/rollback instructions. A `blocked` result must not create a public artifact or expose the submitted content in logs.
172
173## Error Handling
174
175Reject locally when a known restricted pattern, missing consent, unknown
176provenance, disallowed destination, or budget breach is detected. Treat provider
177policy failures as final for that request and report a user-safe revision hint; do
178not claim that sanitization makes an unsafe request permissible. For classifier
179outages or ambiguous results, fail closed into human review. Quarantine any output
180that later receives a complaint, remove its distribution links, preserve only the
181redacted audit receipt, and record the rollback owner.
182
183## Examples
184
185An internal canary decision can be recorded as:
186
187```text
188fixture=synthetic-product-v4; rights=cleared; likeness=none;
189policy=pass-v3; destination=staging-private; canary=watermarked;
190budget=within-limit; approval=pending; decision=approved_for_draft
191```
192
193An identifiable-person image without a consent record must instead return `blocked` and create no generation task.
194
195## Resources
196
197- [Kling AI Terms of Service](https://app.klingai.com/global/dev/document-api/protocols/paidServiceProtocol)
198- [Developer Portal](https://app.klingai.com/global/dev)