Claude Code Cost Control: Prompt Caching, Effort Levels & Model Tiering
Keep Claude Code bills predictable on pay-as-you-go API keys: stay inside the 5-minute cache window for 0.05×/0.025× reads, tune CLAUDE_CODE_EFFORT_LEVEL, default to Sonnet 5.5 or Opus 5.5, and enforce sub-key spend caps.
1. Why Native /v1/messages Prompt Caching Cuts Claude Code Spend by 70%–90%
In an agentic coding session, Claude Code resends your system instructions, tool schemas, CLAUDE.md, and recent file context on every turn. Over native Anthropic POST /v1/messages (configured via Claude Code Custom Base URL Setup), DeepClub passes Anthropic prompt caching straight through:
| Model ID | Official Cache Read Multiplier | Best Role in Claude Code | Minimum CLI Version |
|---|---|---|---|
claude-sonnet-5-5 |
0.05× base input (95% off) | High-throughput daily coding, unit tests, lint/type fixes | v2.1.284+ |
claude-opus-5-5 |
0.05× base input (95% off) | Default flagship for multi-file refactors & complex debugging | v2.1.280+ |
claude-fable-5-2 |
0.025× base input (97.5% off) | Escalation-only standalone ultra-flagship for multi-hour autonomy | v2.1.321+ |
Because the default cache TTL is 5 minutes, consecutive turns sent within 5 minutes of each other read almost the entire prompt prefix at 0.05× or 0.025×. Pausing for 10 minutes mid-task expires the cache and forces a full cache_write on the next turn.
2. Practical Effort & Model Escalation Workflow
Instead of running maximum thinking effort on routine edits, keep your default lean in ~/.claude/settings.json and escalate per session:
{
"env": {
"ANTHROPIC_BASE_URL": "https://deepclub.net",
"ANTHROPIC_AUTH_TOKEN": "sk-your-claude-code-subkey",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"CLAUDE_CODE_EFFORT_LEVEL": "medium"
}
}
# Routine feature work & test loops (fast, low output token overhead)
claude
# Cross-file architecture refactor or tricky bug investigation
claude --model claude-opus-5-5
# Multi-hour autonomous root-cause investigation (pair with a capped sub-key)
CLAUDE_CODE_EFFORT_LEVEL=high claude --model claude-fable-5-2
3. Four Habits That Prevent Runaway Agent Bills
- Issue a dedicated Claude Code sub-key with a hard quota limit: Create a scoped key in DeepClub Console restricted to
claude-sonnet-5-5,claude-opus-5-5, and (optionally)claude-fable-5-2. Even if an autonomous loop stalls, it cannot drain your main account balance. - Run
/clearbetween unrelated tickets: Carrying 120K tokens of stale files into a brand-new task wastes both cache writes and reasoning tokens. - Run
/compactbefore context bloats past 150K–200K: Summarizing completed subtasks preserves decisions while shrinking per-turn prompt size. - Audit
cache_readvsinputin DeepClub Usage Logs: After a 10-turn session, verify thatcache_readdominates total input tokens; ifcache_readstays near zero, inspect whether a proxy or local hook is mutating the prompt prefix between turns (see LLM Prompt Caching Guide).
Related Guides
- Claude Code Custom Base URL Setup · Fix Claude Code 404, 401 & 400 Errors
- Claude 5.x 3-Tier Ladder (Fable / Opus / Sonnet) · Live API Pricing
Frequently Asked Questions
- Does prompt caching discount Claude Code output and thinking tokens?
- No. Prompt caching applies only to matched input prefix tokens (0.05x on Opus/Sonnet 5.5 and 0.025x on Fable 5.2). Output and adaptive thinking tokens are billed at the standard output rate on /en/pricing.
- Should I use Sonnet 5.5 or Opus 5.5 as my default Claude Code model?
- Start with claude-sonnet-5-5 for high-volume daily coding and test fixes, or claude-opus-5-5 if your work is mostly cross-file refactoring. Reserve claude-fable-5-2 for hard multi-hour escalations with a capped sub-key.
- How do I check my real Claude Code cache hit rate?
- Open DeepClub Console Usage Logs and inspect input, cache_write, and cache_read token counts per request. Healthy active sessions typically show 75%–90%+ of prompt tokens served as cache_read.
Updated