Agent skill · data analytics · jeremylongshore
langfuse-cost-tuning
Monitor and optimize LLM costs using Langfuse analytics and dashboards.
Why this skill is useful
Provides specific commands and patterns for tracking and optimizing LLM costs using Langfuse, which the AI wouldn't reliably generate on its own.
What it needs
Requires @langfuse/client installed locally. Requires langfuse account access. About 5k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Langfuse Cost Tuning Overview Track, analyze, and optimize LLM costs using Langfuse's built-in token/cost tracking, the Metrics API for programmatic cost analysis, model routing for cost reduction, and automated budget alerts. Prerequisites Langfuse tracing with token usage captured (via observeOpenAI or manual usage fields) For Metrics API: @langfuse/client installed Understanding of LLM pricing models How Langfuse Tracks Costs Langfuse automatically calculates costs for supported models (OpenAI, Anthropic, Google) when token usage is captured. For custom models, you can configure pricing in the Langfuse UI under Settings > Model Definitions. Cost tracking works on observations of type generation and embedding. The observeOpenAI wrapper captures usage automatically; for manual tracing, include usage in your observation updates. Instructions Step 1: Ensure Token Usage is Captured Step 2: Query Costs via Metrics API Step 3: Implement Smart Model Routing Route requests to cheaper models when appropriate: Step 4: Budget Alerts Langfuse Dashboard Features Langfuse provides built-in cost analytics in the UI: Cost Dashboard: Tracks token usage and costs over time by model, user, and session Latency Dashboard: Response times across models and user segments Custom Dashboards: Build custom views with multi-level aggregations Pricing Tiers: Supports complex pricing (cached tokens, audio tokens, per-model tiers) Cost Optimization Strategies Strategy Savings Effort How ---------- --------- -------- ----- Model downgrade 50-95% Low Route simple tasks to gpt-4o-mini Prompt optimization 10-30% Low Remove filler words, use structured prompts Response caching 20-80% Medium Cache identical prompts with TTL Batch processing 50% Medium Use OpenAI Batch API for offline tasks Token limits 10-40% Low Set maxtokens on all calls Error Handling Issue Cause Solution ------- ------- ---------- Missing cost data No usage in generation Ensure usage is included with promptTokens/completionTokens …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/langfuse-cost-tuning--eb3588