llm-cost-optimization
Reduce LLM API and infrastructure costs through model selection, prompt caching, batching, caching, quantization, and self-hosting strategies. Track spend by team and model, set budgets, and implement cost-aware routing.
npx skills add majiayu000/claude-skill-registry --skill llm-cost-optimization-bagelhole-devops-security-agen --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# LLM Cost Optimization Cut LLM costs by 50–90% with the right combination of caching, model selection, prompt optimization, and self-hosting. ## When to Use This Skill Use this skill when: - LLM API spend is growing faster than revenue - You need to attribute AI costs to teams, products, or customers - Implementing caching to avoid redundant LLM calls - Deciding when to switch from API providers to self-hosted models - Optimizing prompt length without sacrificing quality ## Cost Levers by Impact | Strategy | Typical Savings | Effort | |----------|-----------------|--------| | Semantic caching | 20–50% | Low | | Model right-sizing | 30–70% | Low | | Prompt compression | 10–30% | Medium | | Provider caching (prompt cache) | 10–25% | Low | | Batching offline workloads | 50% (Batch API) | Medium | | Self-hosting 7–8B models | 80–95% at scale | High | | Quantization | 30–50% VRAM cost | Medium | ## Track Costs First ```python # Use LiteLLM's cost tracking (automatic per-model pricing) import litellm response = litellm.completion( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello"}], ) cost = litellm.completion_cost(response) print(f"Cost: ${cost:.6f}") # Add custom cost
- When to Use This Skill
- Cost Levers by Impact
- Track Costs First
- Model Right-Sizing
- Prompt Caching (Provider-Side)
- Batching with OpenAI Batch API (50% Discount)
- Semantic Caching
- Prompt Compression
- Self-Hosting Break-Even Calculator
- Cost Dashboard (Grafana)
- Best Practices
- Related Skills
What does the llm-cost-optimization skill do?
Reduce LLM API and infrastructure costs through model selection, prompt caching, batching, caching, quantization, and self-hosting strategies. Track spend by team and model, set budgets, and implement cost-aware routing.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill llm-cost-optimization-bagelhole-devops-security-agen --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
