borghei/Claude-Skills / engineering/llm-cost-optimizer
llm-cost-optimizer
VerifiedEstimates LLM token counts and per-request cost across models, flags wasteful prompt text, and models prompt-cache break-even. Use when budgeting LLM spend, comparing models on cost, or trimming prompt tokens.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.3 KB |
| assets/sample_prices.json | config | 313 B |
| assets/sample_prompt.txt | markdown | 124 B |
| references/caching-and-batch-economics.md | markdown | 8.6 KB |
| references/llm-pricing-guide.md | markdown | 3.2 KB |
| scripts/cache_savings_calculator.py | script | 8.3 KB |
| scripts/prompt_optimizer.py | script | 15.1 KB |
| scripts/token_counter.py | script | 11.8 KB |
references/llm-pricing-guide.md
View on GitHub# LLM Pricing Guide
## Token Estimation
### What is a Token?
Tokens are the basic units LLMs process. Roughly:
- 1 token ~ 4 characters in English
- 1 token ~ 0.75 words
- 100 tokens ~ 75 words
- 1,000 tokens ~ 750 words
### Tokenizer Differences
Different models use different tokenizers:
- **GPT-4/GPT-4o**: cl100k_base (100K vocabulary)
- **Claude**: Custom BPE tokenizer (~100K vocabulary)
- **Llama/Mistral**: SentencePiece-based
- **Gemini**: SentencePiece-based
Token counts can vary 10-20% between tokenizers for the same text.
## Pricing Table (illustrative snapshot, Q1 2026)
These figures are illustrative and not verified against current provider pages. Check each provider's pricing page, and pass real rates to `token_counter.py --prices FILE`.
### OpenAI Models
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Context Window |
|-------|----------------------|------------------------|----------------|
| GPT-4o | $2.50 | $10.00 | 128K |
| GPT-4o-mini | $0.15 | $0.60 | 128K |
| GPT-4 Turbo | $10.00 | $30.00 | 128K |
| o1 | $15.00 | $60.00 | 200K |
| o1-mini | $3.00 | $12.00 | 128K |
| o3-mini | $1.10 | $4.40 | 200K |
### Anthropic Models
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Context Window |
|-------|----------------------|------------------------|----------------|
| Claude Fable 5.1 | $10.00 | $50.00 | 1M |
| Claude Opus 5.5 | $4.00 | $20.00 | 1M |
| Claude Opus 5 | $5.00 | $25.00 | 1M |
| Claude Sonnet 5 | $2.00 | $10.00 | 1M |
| Claude Haiku 4.5 | $1.00 | $5.00 | 200K |
### Google Models
| Model | Input (per 1M tokens) | Output (per 1M tokens) | Context Window |
|-------|----------------------|------------------------|----------------|
| Gemini 2.0 Pro | $1.25 | $5.00 | 1M |
| Gemini 2.0 Flash | $0.075 | $0.30 | 1M |
| Gemini 1.5 Pro | $1.25 | $5.00 | 2M |
### Open Source (Self-Hosted Cost Estimates)
| Model | GPU Required | Approx. Cost/hr | Equivalent per 1M tokens |
|-------|-------------|-----------------|--------------------------|
| Llama 3 70B | 2x A100 80GB | $6.00 | ~$0.50 |
| Llama 3 8B | 1x A100 40GB | $3.00 | ~$0.10 |
| Mistral 7B | 1x A100 40GB | $3.00 | ~$0.08 |
## Cost Optimization Strategies
### 1. Model Tiering
Route requests to the cheapest model that meets quality requirements:
- **Tier 1** (cheap): Classification, extraction, formatting -> GPT-4o-mini, Haiku
- **Tier 2** (mid): Summarization, Q&A, code review -> GPT-4o, Sonnet
- **Tier 3** (premium): Complex reasoning, creative writing -> o1, Opus
### 2. Prompt Compression
- Remove filler words and redundant instructions
- Use abbreviations in system prompts
- Replace examples with schema definitions
- Typical savings: 20-40% token reduction
### 3. Response Caching
- Cache responses for identical prompts (exact match)
- Use semantic caching for similar prompts (embedding similarity)
- Typical savings: 30-60% cost reduction for repetitive workloads
### 4. Batching
- Combine multiple small requests into one prompt
- Use structured output to parse multiple results
- Typical savings: 15-30% from reduced overhead tokens
### 5. Context Window Management
- Summarize long conversations instead of sending full history
- Use RAG to inject only relevant context
- Implement sliding window for chat applications
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |