klingai-usage-analytics
Build usage analytics and reporting for Kling AI video generation. Use when tracking patterns, analyzing costs, or building dashboards. Trigger with phrases like 'klingai analytics', 'kling ai usage report', 'klingai metrics', 'video generation stats'.
Best use case
klingai-usage-analytics is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Build usage analytics and reporting for Kling AI video generation. Use when tracking patterns, analyzing costs, or building dashboards. Trigger with phrases like 'klingai analytics', 'kling ai usage report', 'klingai metrics', 'video generation stats'.
Teams using klingai-usage-analytics should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/klingai-usage-analytics/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How klingai-usage-analytics Compares
| Feature / Agent | klingai-usage-analytics | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Build usage analytics and reporting for Kling AI video generation. Use when tracking patterns, analyzing costs, or building dashboards. Trigger with phrases like 'klingai analytics', 'kling ai usage report', 'klingai metrics', 'video generation stats'.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Marketing
Discover AI agents for marketing workflows, from SEO and content production to campaign research, outreach, and analytics.
Best AI Agents for Marketing
A curated list of the best AI agents and skills for marketing teams focused on SEO, content systems, outreach, and campaign execution.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Kling AI Usage Analytics
## Overview
Track video generation usage with structured logging, aggregate metrics, daily reports, and cost analysis. Built on JSONL event logs that can feed into any analytics platform.
## Event Logger
```python
import json
import time
from datetime import datetime
from pathlib import Path
class KlingEventLogger:
"""Append-only JSONL event log for Kling AI operations."""
def __init__(self, log_dir: str = "logs"):
self.log_dir = Path(log_dir)
self.log_dir.mkdir(exist_ok=True)
def _write(self, event: dict):
date = datetime.utcnow().strftime("%Y-%m-%d")
filepath = self.log_dir / f"kling-{date}.jsonl"
event["timestamp"] = datetime.utcnow().isoformat()
with open(filepath, "a") as f:
f.write(json.dumps(event) + "\n")
def log_submission(self, task_id, prompt, model, duration, mode):
self._write({
"event": "task_submitted",
"task_id": task_id,
"model": model,
"duration": int(duration),
"mode": mode,
"prompt_len": len(prompt),
})
def log_completion(self, task_id, status, elapsed_sec, credits_used):
self._write({
"event": "task_completed",
"task_id": task_id,
"status": status,
"elapsed_sec": elapsed_sec,
"credits_used": credits_used,
})
def log_error(self, task_id, error_type, message):
self._write({
"event": "task_error",
"task_id": task_id,
"error_type": error_type,
"message": message[:200],
})
```
## Analytics Aggregator
```python
from collections import defaultdict
class UsageAnalytics:
"""Aggregate metrics from JSONL event logs."""
def __init__(self, log_dir: str = "logs"):
self.log_dir = Path(log_dir)
def _read_events(self, date: str = None):
pattern = f"kling-{date}.jsonl" if date else "kling-*.jsonl"
events = []
for filepath in sorted(self.log_dir.glob(pattern)):
with open(filepath) as f:
for line in f:
events.append(json.loads(line))
return events
def daily_summary(self, date: str = None) -> dict:
date = date or datetime.utcnow().strftime("%Y-%m-%d")
events = self._read_events(date)
submitted = [e for e in events if e["event"] == "task_submitted"]
completed = [e for e in events if e["event"] == "task_completed"]
errors = [e for e in events if e["event"] == "task_error"]
succeeded = [e for e in completed if e["status"] == "succeed"]
failed = [e for e in completed if e["status"] == "failed"]
total_credits = sum(e.get("credits_used", 0) for e in completed)
avg_elapsed = (sum(e["elapsed_sec"] for e in succeeded) / len(succeeded)
if succeeded else 0)
by_model = defaultdict(int)
for e in submitted:
by_model[e["model"]] += 1
return {
"date": date,
"total_submitted": len(submitted),
"succeeded": len(succeeded),
"failed": len(failed),
"errors": len(errors),
"success_rate": f"{len(succeeded) / max(len(completed), 1) * 100:.1f}%",
"total_credits": total_credits,
"avg_generation_sec": round(avg_elapsed),
"by_model": dict(by_model),
}
def print_report(self, date: str = None):
s = self.daily_summary(date)
print(f"\n=== Kling AI Usage Report: {s['date']} ===")
print(f"Submitted: {s['total_submitted']}")
print(f"Succeeded: {s['succeeded']}")
print(f"Failed: {s['failed']}")
print(f"Success rate: {s['success_rate']}")
print(f"Credits used: {s['total_credits']}")
print(f"Avg time: {s['avg_generation_sec']}s")
print(f"By model:")
for model, count in s["by_model"].items():
print(f" {model}: {count}")
```
## Cost Analysis
```python
def cost_analysis(analytics: UsageAnalytics, days: int = 7):
"""Analyze cost trends over recent days."""
from datetime import timedelta
daily_costs = []
for i in range(days):
date = (datetime.utcnow() - timedelta(days=i)).strftime("%Y-%m-%d")
summary = analytics.daily_summary(date)
daily_costs.append({
"date": date,
"credits": summary["total_credits"],
"videos": summary["total_submitted"],
"estimated_usd": summary["total_credits"] * 0.14,
})
total_credits = sum(d["credits"] for d in daily_costs)
total_videos = sum(d["videos"] for d in daily_costs)
total_cost = sum(d["estimated_usd"] for d in daily_costs)
print(f"\n=== {days}-Day Cost Summary ===")
print(f"Total credits: {total_credits}")
print(f"Total videos: {total_videos}")
print(f"Est. cost: ${total_cost:.2f}")
print(f"Avg/day: ${total_cost / days:.2f}")
for d in daily_costs:
print(f" {d['date']}: {d['credits']} credits, {d['videos']} videos, ${d['estimated_usd']:.2f}")
```
## Export to CSV
```python
import csv
def export_usage_csv(analytics: UsageAnalytics, output: str = "kling_usage.csv"):
events = analytics._read_events()
with open(output, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=["timestamp", "event", "task_id",
"model", "status", "credits_used",
"elapsed_sec"])
writer.writeheader()
for e in events:
writer.writerow({k: e.get(k, "") for k in writer.fieldnames})
print(f"Exported {len(events)} events to {output}")
```
## Resources
- [Developer Portal](https://app.klingai.com/global/dev)
- [Pricing Reference](https://app.klingai.com/global/dev/document-api/productBilling/prePaidResourcePackage)Related Skills
windsurf-usage-analytics
Analyze team AI usage patterns and productivity metrics. Activate when users mention "usage analytics", "ai metrics", "productivity tracking", "usage reports", or "roi analysis". Handles analytics and reporting configuration. Use when working with windsurf usage analytics functionality. Trigger with phrases like "windsurf usage analytics", "windsurf analytics", "windsurf".
openrouter-usage-analytics
Track and analyze OpenRouter API usage patterns, costs, and performance. Use when building dashboards, optimizing spend, or reporting on AI usage. Triggers: 'openrouter analytics', 'openrouter usage', 'openrouter metrics', 'track openrouter spend'.
klingai-webhook-config
Configure webhook callbacks for Kling AI task completion. Use when building event-driven pipelines or replacing polling. Trigger with phrases like 'klingai webhook', 'kling ai callback', 'klingai notifications', 'video completion webhook'.
klingai-video-extension
Extend video duration using Kling AI continuation. Use when creating longer videos from shorter clips or building sequences. Trigger with phrases like 'klingai extend video', 'kling ai video continuation', 'klingai longer video', 'extend klingai clip'.
klingai-upgrade-migration
Migrate between Kling AI model versions safely. Use when upgrading from v1.x to v2.x or adopting new features. Trigger with phrases like 'klingai upgrade', 'kling ai migrate', 'klingai version update', 'upgrade kling model'.
klingai-text-to-video
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'.
klingai-team-setup
Configure Kling AI for teams with per-project API keys, usage quotas, and role-based access. Trigger with phrases like 'klingai team', 'kling ai organization', 'klingai multi-user', 'shared klingai access'.
klingai-style-transfer
Apply artistic styles and visual effects to Kling AI video generation. Use when creating stylized content or using effects API. Trigger with phrases like 'klingai style', 'kling ai effects', 'klingai artistic video', 'stylize klingai video'.
klingai-storage-integration
Download and store Kling AI generated videos in cloud storage (S3, GCS, Azure). Use when persisting videos or building CDN pipelines. Trigger with phrases like 'klingai storage', 'save klingai video', 'kling ai s3 upload', 'klingai cloud storage'.
klingai-sdk-patterns
Production SDK patterns for Kling AI: client wrapper, retry logic, async polling, and error handling. Use when building robust integrations. Trigger with phrases like 'klingai sdk', 'kling ai client', 'klingai patterns', 'kling ai wrapper'.
klingai-reference-architecture
Production reference architecture for Kling AI video generation platforms. Use when designing scalable systems. Trigger with phrases like 'klingai architecture', 'kling ai system design', 'video platform architecture', 'klingai production setup'.
klingai-rate-limits
Handle Kling AI API rate limits with backoff and queuing strategies. Use when hitting 429 errors or planning high-volume workflows. Trigger with phrases like 'klingai rate limit', 'kling ai 429', 'klingai throttle', 'kling api limits'.