Problem
pi-web already has the two raw ingredients for cost tracking, but nothing that aggregates them:
What's missing is the aggregation layer: a view that answers "how much have I spent per model this week/month, and where?"
Proposal
A usage statistics page/panel that aggregates across sessions:
- Per model (provider/model id): total input / output / cache-read / cache-write tokens, message count, session count.
- Estimated cost: tokens × the configured pricing preset (from the models.dev catalog or user-overridden prices in
models.json); clearly marked as an estimate, hidden or marked N/A for models without pricing info.
- Time range filtering: today / 7d / 30d / all.
- Data source: scan session
.jsonl files (same read path as the session list) and aggregate assistant message usage blocks — no changes to the agent runtime needed. Results can be cached server-side and invalidated on session file mtime changes.
Nice-to-haves (could be follow-ups): per-project breakdown, CSV export, daily trend chart.
Notes
- Happy to contribute a PR for this. I'd start with a read-only
/api/usage endpoint + a stats panel, no schema changes to session files.
- If maintainers would rather see this as an extension/plugin instead of core UI, let me know and I'll scope it that way.
Problem
pi-web already has the two raw ingredients for cost tracking, but nothing that aggregates them:
.jsonlfiles.What's missing is the aggregation layer: a view that answers "how much have I spent per model this week/month, and where?"
Proposal
A usage statistics page/panel that aggregates across sessions:
models.json); clearly marked as an estimate, hidden or marked N/A for models without pricing info..jsonlfiles (same read path as the session list) and aggregate assistant message usage blocks — no changes to the agent runtime needed. Results can be cached server-side and invalidated on session file mtime changes.Nice-to-haves (could be follow-ups): per-project breakdown, CSV export, daily trend chart.
Notes
/api/usageendpoint + a stats panel, no schema changes to session files.