Skip to main content
See how many tokens and dollars your agents have spent — locally, with one command, no external service.
Run praisonai at least once so a session exists — otherwise the report is empty.

Quick Start

1

See your spend

2

Change the grouping

3

Narrow the window or script it

4

See per-tool reliability

Reports calls, success rate, average latency, and the last error for each tool used.

How It Works

The command reads the already-persisted total_tokens and cost fields on each session record in the local session store, filters by --days, groups by --by, and renders a table or JSON. No new data is written, no network calls, no configuration.
Cost values match praisonai tracker — both read from the same pricing reference.

Choosing --by

Pick the dimension that answers your question. day sorts chronologically; model and project sort by highest token count first. tool sorts by most-called first, so your busiest (or busiest-failing) tool rises to the top.

Options

An invalid --by value prints --by must be one of: day, model, project, tool and exits with code 1.

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.

Python: read the same data with a hook

Prefer Python? The same per-call data is available via the AFTER_TOOL hook — no new API is needed.
The CLI tally reads exactly these three fields.

Output Formats

Zero values render as -, and a final Total row sums the report.

Empty Stores and Warnings

Empty and broken reports are always distinguishable.
  • No sessions yet? The command prints No usage recorded yet and exits 0.
  • A damaged or unreadable store surfaces as Usage may be incomplete: ... in table mode, or in the top-level errors array in JSON mode.

Best Practices

Wire praisonai usage --days 7 --json into a cron or CI job and alert if cost exceeds a threshold.
Run praisonai usage --by model weekly to see which model your agents actually spend the most on.
Use praisonai usage --project <id> inside a workspace and praisonai usage --by project in the default shell to compare workloads.
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.
--json is stable for scripting — pipe into jq or a small dashboard rather than parsing the table.

Token Usage Protocol

Wire custom sinks and queries (databases, dashboards)

Sessions

The store praisonai usage reads from

Cost Tracker

Per-run token and cost tracking