Cost Tracking
Massu AI's cost tracking tools give you full visibility into what your AI-assisted development actually costs. Track token usage per session, attribute spending to individual features, analyze trends over weeks and months, and receive automated alerts before you exceed your budget. Stop guessing at AI costs and start managing them with data.
Why This Matters
Without cost tracking, AI development spend is invisible until the bill arrives:
- You have no idea which features or tasks are the most expensive to build with AI
- High-token sessions go unnoticed until monthly totals appear on your statement
- Cache efficiency, model selection, and prompt length have real cost implications you cannot measure
- Budget overruns happen because there is no early warning system
- Comparing the AI cost of two implementation approaches is impossible
Massu AI's cost tracking makes every dollar of AI spend visible, attributable, and manageable.
Open Source Tools
massu_cost_session
What it does: Track token usage and estimated cost for the current session. Breaks down by tool calls, prompts, and responses, with per-model pricing applied to input tokens, output tokens, cache reads, and cache writes.
Usage:
massu_cost_session
massu_cost_session --session_id "abc123"Example output:
## Session Cost: abc123
Model: claude-opus-4-6
Duration: 45 minutes
### Token Usage
Input tokens: 45,230 ($0.68)
Output tokens: 12,450 ($0.93)
Cache read: 128,000 ($0.19)
Cache write: 8,500 ($0.03)
### Total: $1.83 USD
### Efficiency
Cost per tool call: $0.04
Cost per file edit: $0.12
Cache hit rate: 74%Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
session_id | string | no | Specific session to inspect (default: current session) |
massu_cost_trend
What it does: Analyze cost trends over time. Identify expensive patterns, compare session costs week over week, and forecast spending based on your usage rate. Groups data by day, week, or month and shows model distribution.
Usage:
massu_cost_trend --days 30
massu_cost_trend --group_by "week"Example output:
## Cost Trend (30 days)
### Weekly Summary
Week 1 (Feb 3-9): $12.45 (8 sessions)
Week 2 (Feb 10-16): $9.80 (6 sessions)
Week 3 (Feb 17-23): $14.20 (9 sessions)
Week 4 (Feb 24-28): $8.90 (5 sessions)
### Total: $45.35 USD
Average per session: $1.62
Average per day: $1.51
### Model Distribution
claude-opus-4-6: $38.50 (85%)
claude-sonnet-4-5-20250929: $6.85 (15%)
### Trend
Last 30 days vs prior 30: -8% (IMPROVING)Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
days | number | no | Lookback period in days (default: 30) |
group_by | string | no | Grouping interval: day, week, or month |
massu_cost_feature
What it does: Splits each session's priced cost across the registered features whose files the session touched, in proportion to those touches, and totals it per feature. It is an allocation by activity, not a measured per-feature cost. Register features with massu_sentinel_register; activity on files that belong to no registered feature is reported as (no registered feature), so the rows add up to the sessions' total. Sessions whose cost is unknown are left out.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
days | number | no | Lookback period in days (default: 30) |
Usage:
massu_cost_feature
massu_cost_feature --days 7Example output:
## Feature Cost Attribution (30 days)
Total: $41.20 across 3 feature row(s)
Each session's priced cost is ALLOCATED across the registered features whose files it touched, in proportion to those touches. It is an allocation by activity, not a measured per-feature cost. Sessions with unknown cost are not included.
| Feature | Cost | Tokens | Sessions | % of Total |
|---------|------|--------|----------|------------|
| orders.create | $18.40 | 6,210,000 | 5 | 44.7% |
| (no registered feature) | $14.90 | 5,030,000 | 9 | 36.2% |
| auth.sso | $7.90 | 2,670,000 | 3 | 19.2% |Cloud Pro Features
Cost Dashboard
Cloud Pro adds an interactive web dashboard for AI cost data. Instead of reading CLI output, you get interactive charts with trend lines, model breakdown pie charts, and per-feature cost heat maps. Filter by date range, model, or feature key. Share cost reports with your team or engineering leadership without requiring CLI access.
Budget Alerts
Automated email alerts when your AI spend approaches or exceeds your configured monthly budget threshold. Set a soft limit (warning at 80% of budget) and a hard limit (alert at 100%). Alerts include a cost breakdown so you can immediately see which sessions or features drove the spike. Connects to the same model pricing configuration in massu.config.yaml so alerts reflect your actual negotiated rates.
Cost Forecasting
AI spend projections based on current daily usage patterns, projecting month-end totals from your current spending rate. If you are 10 days into a month and have spent $18, Cost Forecasting projects $54 for the full month and flags whether that is above, below, or on track relative to your configured budget. Adjusts dynamically as your usage changes throughout the month.
Session Comparison
Side-by-side session analytics comparison showing cost, tokens, turns, and tool usage differences between any two sessions. Useful for understanding why one implementation session cost twice as much as another — compare cache hit rates, output token counts, and tool call frequency to identify inefficiencies and replicate high-efficiency sessions.
Configuration
You don't need to configure prices. Massu ships Anthropic's published price list and prices every response at its own model's rates: input, output, cache reads, 5-minute and 1-hour cache writes, fast mode, US-only routing, and Claude Haiku 5.5's higher rate for prompts over 100,000 tokens. Each session shows whether its cost is priced, partial (a model it used has no known price) or unknown (no transcript was available). A model with no price is never guessed.
To override one model's price, for example a negotiated rate, add only that model:
analytics:
cost:
models:
claude-opus-5-5:
input_per_million: 4
output_per_million: 20
cache_read_per_million: 0.2 # optional
cache_write_per_million: 5 # 5-minute cache writes, optional
cache_write_1h_per_million: 8 # 1-hour cache writes, optional
currency: USDAn override replaces the built-in price for that model only; every other model keeps the built-in list. Prices are per million tokens, and currency is a display label.
Tips
- Run
massu_cost_sessionat the end of any session that felt unusually long — cache hit rate below 50% is a sign of context thrashing that you can fix by scoping sessions more tightly - Use
massu_cost_featureat the end of a sprint to include AI costs in your engineering cost accounting alongside compute and developer time - Switch to
claude-sonnet-4-5-20250929for research, exploration, and question-answering tasks — it costs 80% less than Opus and performs equally well for non-implementation work - Cost trends are most useful when sessions are focused on a single feature or task; mixed-purpose sessions make attribution unreliable