klingai-content-policy
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'.
What this skill does
# 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
```python
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:
```python
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
```python
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
```python
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:
1. **Filter before API call** -- saves credits on obvious violations
2. **Explain rejections clearly** -- tell users what to change
3. **Log violations** -- track patterns for filter improvement
4. **Rate limit prompt submissions** -- prevent abuse
5. **Review flagged content** -- human review for edge cases
## Resources
- [Kling AI Terms of Service](https://app.klingai.com/global/dev/document-api/protocols/paidServiceProtocol)
- [Developer Portal](https://app.klingai.com/global/dev)
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.