From langfuse-pack
Monitor and optimize LLM costs using Langfuse analytics and dashboards. Use when tracking LLM spending, identifying cost anomalies, or implementing cost controls for AI applications. Trigger with phrases like "langfuse costs", "LLM spending", "track AI costs", "langfuse token usage", "optimize LLM budget".
How this skill is triggered — by the user, by Claude, or both
Slash command
/langfuse-pack:langfuse-cost-tuningThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Track, analyze, and optimize LLM costs using Langfuse observability data with token tracking, cost alerts, model selection optimization, and automated reporting.
Record prompt and completion tokens on each generation.end() call. Calculate cost using per-model pricing tables and store as metadata.
Fetch generations from Langfuse and aggregate costs by model, by day, and by token type. Calculate total cost and generation count.
Build a CostMonitor that tracks hourly and daily spend. Define thresholds (e.g., $100/day warn, $500/day notify, $1/request warn). Send Slack/PagerDuty notifications on breaches.
Route simple tasks (summarize, classify, extract) and short inputs to cheaper models (GPT-4o-mini). Reserve expensive models for complex tasks (analyze, reason, code).
Cache LLM responses with TTL. Strip redundant whitespace and filler words from prompts to reduce token count.
See detailed implementation for advanced patterns.
| Issue | Cause | Solution |
|---|---|---|
| Missing usage data | SDK not capturing | Verify generation.end() includes usage |
| Inaccurate costs | Wrong pricing | Update MODEL_PRICING regularly |
| Budget exceeded | No alerts | Implement cost alerts |
| Report failures | API limits | Add pagination to fetchGenerations |
| Model | Input (per 1M) | Output (per 1M) |
|---|---|---|
| GPT-4 Turbo | $10.00 | $30.00 |
| GPT-4o | $5.00 | $15.00 |
| GPT-4o-mini | $0.15 | $0.60 |
| Claude 3 Opus | $15.00 | $75.00 |
| Claude 3 Sonnet | $3.00 | $15.00 |
| Claude 3 Haiku | $0.25 | $1.25 |
| Strategy | Potential Savings | Effort |
|---|---|---|
| Model downgrade | 50-90% | Low |
| Prompt optimization | 10-30% | Low |
| Response caching | 20-60% | Medium |
| Batch processing | 10-20% | Medium |
npx claudepluginhub ktiseos-nyx/claude-code-plugins-plus-skills --plugin langfuse-packGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.
Dispatches multiple subagents concurrently for independent tasks without shared state. Use when facing 2+ unrelated failures or subsystems that can be investigated in parallel.
4plugins reuse this skill
First indexed Jul 11, 2026