praisonai usage reads the token and cost totals PraisonAI already saves per session and rolls them up by day, model, or project.
Quick Start
1
See your spend
Run one line to see the last 30 days grouped by day.
2
Group differently
Switch the grouping to see spend by model or by project.
3
Group by project (current vs global stores)
4
Last 7 days only
5
A single project
6
Get JSON for scripts
Add
--json for machine-readable output you can pipe to jq.This command reads data that
praisonai run already saved to disk — no setup, no re-instrumentation, no external observability platform.Choose Your Grouping
Pick the--by value that matches the question you’re asking.
How It Works
praisonai usage reads the same session files that praisonai session list shows — nothing new is written, no external service is contacted.
When
--project is omitted, both stores are scanned separately and session ids shared across them are de-duplicated (the current-project store wins). Each store is scanned up to 100,000 sessions to keep memory predictable — realistic stores are never truncated.
Options
Every option is optional —praisonai usage with no flags reports the last 30 days by day.
--by day sorts chronologically (ascending); --by model and --by project sort by tokens descending (highest spend first).
JSON output shape
--json emits a stable object you can pipe into dashboards or cron jobs.
Empty output
- Table:
No usage recorded yet - JSON:
{"rows": [], "total_tokens": 0, "cost": 0.0, ...}
Store errors
A missing or damaged store is non-fatal. Table mode printsUsage may be incomplete: <reason> as a warning; JSON mode exposes the reasons under errors. The command still exits 0 and returns whatever it could read — a broken store is never silently reported as empty. An invalid --by value exits 1 with --by must be one of: day, model, project.
Common Patterns
Practical one-liners for everyday reviews.Grouping Modes
Best Practices
Find your most expensive models
Find your most expensive models
Run
praisonai usage --by model — models are sorted by highest token count first, so the biggest spenders appear at the top.Report across all history
Report across all history
Use
praisonai usage --days 0 to disable the time filter and aggregate every session on disk, not just the last 30 days. Use this sparingly on very large session directories, since it scans up to 100,000 records per store.Feed usage into scripts
Feed usage into scripts
praisonai usage --json emits a stable shape (by, days, project, rows, total_tokens, cost, errors) that is safe to parse in CI or dashboards. The global JSON output mode auto-enables JSON, so scripts running under it get machine-readable output without passing --json explicitly.Trust the numbers
Trust the numbers
Watch for
Usage may be incomplete warnings. They mean a store could not be read fully — check filesystem permissions on the session store path and look for corrupt records. The totals shown exclude that store rather than silently reporting zero. In --json mode the same reasons appear in the errors array.Attribute cost per workspace
Attribute cost per workspace
Combine
--project my-app with --by model to see which model drives spend inside one project.Script budget checks
Script budget checks
Pipe
--json output to jq in CI to fail a build when spend crosses a threshold.Missing cost? Check pricing coverage
Missing cost? Check pricing coverage
Cost only appears for models present in the default pricing table. See Cost Tracking to add custom pricing.
Read current vs global buckets correctly
Read current vs global buckets correctly
Without
--project, --by project splits usage into a current bucket (this project’s store) and a global bucket (the default store). Shared session IDs appear once. Pass --project my-app to report a single project only.Related
Cost Tracking
Per-run and per-session cost source
Session
The underlying session store
Tracker
Per-run execution tracker
Metrics
Performance metrics

