praisonai usage reads the token and cost totals PraisonAI already saves per session and rolls them up by day, model, or project β or reports per-tool reliability with --by tool.
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.7
See per-tool reliability
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.
tool sorts by most-called first, so your busiest (or busiest-failing) tool rises to the top.
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); --by tool sorts by call count descending, then alphabetically.
JSON output shape
--json emits a stable object you can pipe into dashboards or cron jobs.
--by tool, each row describes a tool instead of a spend bucket:
total_tokens / cost fields β it reports outcomes, not spend.
Empty output
- Table:
No usage recorded yet - JSON:
{"rows": [], "total_tokens": 0, "cost": 0.0, ...} --by tooltable:No tool usage recorded yet
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, tool.
Common Patterns
Practical one-liners for everyday reviews.Grouping Modes
Per-Tool Reliability
praisonai usage --by tool reports per-tool call counts, success rate, average and last latency, and the last error β read from the local session store, same as every other grouping.
Last ms and Last error are picked by when the tool itself last ran, not by when the session was last updated. If no tool calls are recorded, the command prints No tool usage recorded yet.
The tally counts tool outcomes that reach the
AFTER_TOOL hook β which covers normalised tool failures (the common case). A raw exception that escapes the tool retry loop does not fire AFTER_TOOL and is not counted.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.Spot flaky or slow tools before users notice
Spot flaky or slow tools before users notice
Run
praisonai usage --by tool --days 7 as part of your weekly review. Rows are sorted by call count first, so the busiest tool is on top β and the Success column immediately shows which ones are quietly failing. Pipe --json into jq in CI to fail a build when any tool drops below your target success rate.Related
Cost Tracking
Per-run and per-session cost source
Session
The underlying session store
Tracker
Per-run execution tracker
Metrics
Performance metrics

