claude-api-cost-optimization
Save 50-90% on Claude API costs with Batch API, Prompt Caching & Extended Thinking. Official techniques, verified.
npx skills add majiayu000/claude-skill-registry --skill claude-api-cost-optimization --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.
# Claude API Cost Optimization > Save 50-90% on Claude API costs with three officially verified techniques ## Quick Reference | Technique | Savings | Use When | |-----------|---------|----------| | **Batch API** | 50% | Tasks can wait up to 24h | | **Prompt Caching** | 90% | Repeated system prompts (>1K tokens) | | **Extended Thinking** | ~80% | Complex reasoning tasks | | **Batch + Cache** | ~95% | Bulk tasks with shared context | --- ## 1. Batch API (50% Off) ### When to Use - Bulk translations - Daily content generation - Overnight report processing - NOT for real-time chat ### Code Example ```python import anthropic client = anthropic.Anthropic() batch = client.messages.batches.create( requests=[ { "custom_id": "task-001", "params": { "model": "claude-sonnet-4-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Task 1"}] } } ] ) # Results available within 24h (usually <1h) for result in client.messages.batches.results(batch.id): print(f"{result.custom_id}: {result.result.message.content[0].text}") ``` ### Key Finding: Bigger Batches = Faster! | Batch Size | Time/Request | |------------|--------------| | Large (294) | **0.45 min** | | Small (10) | 9.84 min | **22x
- Quick Reference
- 1. Batch API (50% Off)
- When to Use
- Code Example
- Key Finding: Bigger Batches = Faster!
- 2. Prompt Caching (90% Off)
- Cache Rules
- 3. Extended Thinking (~80% Off)
- Decision Flowchart
- Official Docs
What does the claude-api-cost-optimization skill do?
Save 50-90% on Claude API costs with Batch API, Prompt Caching & Extended Thinking. Official techniques, verified.
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill claude-api-cost-optimization --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.
