Cost Overview Card
The dashboard displays total cost in the stats overview section.Implementation
Fromsrc/components/stats-overview.tsx:41:
- Total Cost: Formatted USD amount (
formatCostutility) - Model Count: Number of different models used
- Click to navigate to detailed model analytics
Cost Calculation
Costs are calculated based on token usage and model-specific pricing.Token Types and Pricing
Claude API charges different rates for different token types:- Input tokens: Standard rate for prompt text
- Output tokens: Higher rate for generated text
- Cache read tokens: Reduced rate (90% cheaper)
- Cache creation tokens: Additional cost for writing to cache
Cost Data Structure
Costs are stored per model in theModelUsage interface (src/lib/types.ts:48):
The
costUSD field contains the pre-calculated total cost for all token types and web searches for that model.Cost Breakdown Table
Detailed cost information appears in the Token Details table within Model Analytics.Table Structure
Fromsrc/components/model-breakdown.tsx:126:
Per-Model Costs
Each row shows:- Individual model costs
- Token counts that contributed to the cost
- Web search request counts (if applicable)
Total Row
The table footer sums costs across all models:Cost Formatting
Costs are consistently formatted using theformatCost utility from src/lib/utils.ts:22:
- Dollar sign prefix
- Two decimal places
- Consistent formatting across the application
Cost Optimization Insights
Prompt Caching Benefits
The Token Details table makes it easy to see cache efficiency:- Cache Read tokens: Show how much context is being reused
- Standard Input tokens: Show fresh context costs
- Ratio: Compare cache reads to standard inputs for efficiency
Model Selection
The cost breakdown helps identify:- Which models consume the most budget
- Whether cheaper models could handle certain tasks
- Cost per session or per project
Web Search Costs
If you use Claude’s web search feature, costs are tracked separately.Display Logic
The web search column appears conditionally:Cost Inclusion
Web search costs are included in thecostUSD field alongside token costs.
Historical Cost Tracking
While not explicitly visualized in a dedicated chart, cost data can be derived from:- Daily Token Usage Chart: Multiply daily tokens by model rates
- Session Explorer: View per-session token usage and calculate costs
- Activity Tracking: Correlate activity patterns with spending
Accessing Cost Information
Quick View
Click the “Total Cost” card in the stats overview to jump to Model Analytics:Detailed View
Navigate to the “Models” tab for comprehensive cost breakdowns:Cost Data Source
Costs are calculated during stats cache generation from:- Session metadata files in
~/.config/Claude Code/sessions/ - Token usage recorded in each session
- Known model pricing (built into the analytics system)
Session Token Fields
Session Token Fields
Each session file tracks token usage:These values are aggregated across all sessions and combined with model pricing to calculate costs.
Related Features
- Model Analytics - Full token and cost breakdown
- Session Explorer - Per-session token usage
- Activity Tracking - Temporal cost patterns