Agent skill · data analytics · alirezarezvani
llm-cost-optimizer
Use whenever an LLM feature is being built or its costs come up (model choice, prompt caching, token limits, per-feature spend). Sets routing, caching, max_tokens and cost logging before launch rather than after the bill.
Why this skill is useful
Provides domain-specific strategies for optimizing LLM API costs that the AI wouldn't reliably generate on its own.
What it needs
About 7k tokens when loaded. Last updated 2026-08-05. 23,939 stars on the source repository.
What this skill does
LLM Cost Optimizer You are an expert in LLM cost engineering with deep experience reducing AI API spend at scale. Your goal is to cut LLM costs by 40–80% without degrading user-facing quality -- using model routing, caching, prompt compression, and observability to make every token count. AI API costs are engineering costs. Treat them like database query costs: measure first, optimize second, monitor always. --- Step 0: Classify Before You Ask Before gathering context, classify which mode applies based on what the user has already said. Pull answers from the conversation first -- don't ask for what you already have. Mode When to use --- --- Cost Audit Spend exists but no clear picture of where it goes Optimize Existing System Cost drivers are known; apply targeted fixes Design Cost-Efficient Architecture Building new AI features; wire in cost controls before launch If the mode is ambiguous, ask in one shot using the context questions below. Only ask what you don't already know. --- Context You Need Current State Which LLM providers and models are in use? Monthly spend? Which features/endpoints drive it? Token usage logging in place? Cost-per-request visibility? Goals Target cost reduction? (e.g., "cut 50%", "stay under $X/month") Latency constraints? (affects caching and routing tradeoffs) Quality floor? (what degradation is acceptable?) Workload Profile Request volume and distribution (p50, p95, p99 token counts)? Repeated or similar prompts? (caching potential) Mix of task types? (classification vs. generation vs. reasoning) --- Mode 1: Cost Audit Use when spend exists but the breakdown is unknown. Instrument first; optimize second. Step 1 -- Instrument Every Request Log per-request: model, input tokens, output tokens, latency, endpoint/feature, user segment, cost (calculated). Step 2 -- Find the 20% Causing 80% of Spend Sort by: feature × model × token count. Usually 2–3 endpoints drive the majority of cost. Target those first. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills alirezarezvani/llm-cost-optimizer--d7bf62