AI Usage
v0.17.1Token usage and cost from Claude Code, Codex CLI and OpenCode data.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
usage_summary Usage summary
Total token usage and cost for a period, split by client (Claude Code, OpenCode, Codex). Tokens are broken out into input / output / cache-read / cache-write / reasoning, because cache tokens typically dwarf input and a single blended total is misleading. Reported cost (from OpenCode) and estimated cost (computed for Claude Code and Codex, which record none) are always listed separately and must not be summed. Also reports the cache hit rate and reads-per-write, which are what say whether the cache is paying for itself -- the raw cache counts alone cannot.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
compare | string | Also report the equally long window just before this one, with the delta. Needs a fixed-length period (days, today, or since AND until); an open-ended one is rejected. |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
session_usage Session usage
Usage for one session: client, model(s), duration, token breakdown and cost. Accepts a full session id or an unambiguous fragment of one. Subagent turns are reported separately from main-thread turns.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session id, or an unambiguous part of one. |
includeSubagents | boolean | Include subagent turns in the totals. Defaults to true. |
model_usage Usage by model
Per-model token usage and cost, highest token count first. Use this to answer "which model consumed the most tokens". Cost is labelled reported vs estimated per model.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
limit | integer | Rows to return. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
offset | integer | Rows to skip; pass `nextOffset` from the previous result. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
sort | string | Descending order. Reported and estimated cost are never summed, so there is no plain "cost": pick the basis you mean. |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
client_usage Usage by client
Token usage and cost per coding agent (Claude Code, OpenCode, Codex). Note that the two cost figures are not comparable as a single number: OpenCode reports actual charged cost, while the Claude Code and Codex figures are API-equivalent estimates (a subscription has $0 marginal cost per request).
| Parameter | Type | Description |
|---|---|---|
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
limit | integer | Rows to return. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
offset | integer | Rows to skip; pass `nextOffset` from the previous result. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
sort | string | Descending order. Reported and estimated cost are never summed, so there is no plain "cost": pick the basis you mean. |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
project_usage Usage by project
Per-project token usage and cost, highest token count first. A project is the working directory a turn ran in. Use this to answer "which repository is my spend going to". Turns whose project could not be resolved are grouped as (unknown) rather than dropped, and cost is labelled reported vs estimated per project.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
limit | integer | Rows to return. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
offset | integer | Rows to skip; pass `nextOffset` from the previous result. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
sort | string | Descending order. Reported and estimated cost are never summed, so there is no plain "cost": pick the basis you mean. |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
daily_usage Usage by day
Token usage and cost bucketed on the time axis, newest first. Use this for "how much did I use yesterday", for a trend over a period, or -- with grain "hour-of-day" -- for "when during the day do I burn tokens". Buckets with NO activity are included and flagged `zeroFilled`, because omitting them hides the gaps and makes an ordinary bucket look like a spike beside one weeks earlier. All buckets are local time, so they agree with the period filter rather than drifting by a timezone offset. Cost is labelled reported vs estimated per bucket.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
grain | string | Time bucket, local time (default day). "hour-of-day" folds every day onto one 24-slot clock: "when during the day do I burn tokens". |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
usage_breakdown Usage broken down by two dimensions
Token usage and cost cut by two or more dimensions at once -- project x day, model x day, client x day -- as one tidy row set. Use this for "which of my projects is getting more expensive", which the single-axis tools cannot answer: project_usage gives a total with no trend, and daily_usage narrowed to one project gives one series, so answering it otherwise means enumerating projects and issuing one call each. Combinations with no activity are absent rather than returned as zero rows. Cost stays labelled reported vs estimated per row and the two are never summed.
| Parameter | Type | Description |
|---|---|---|
axes * | array | Dimensions to cross, in output order: client, model, provider, project, session, day, hour, hour-of-day. At most 3, and each at most once. The time axes bucket in local time, identically to daily_usag… |
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
limit | integer | Rows to return. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
offset | integer | Rows to skip; pass `nextOffset` from the previous result. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
sort | string | Descending order. Reported and estimated cost are never summed, so there is no plain "cost": pick the basis you mean. |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
counterfactual_cost Cost on another model
What the tokens from a period would have cost at another model’s list rates, alongside what they actually cost. Use this for "would Sonnet have been cheaper than Opus for this". It re-prices the exact token counts that were recorded, grouped by client, model and speed so the fast-mode premium and the two different reasoning-token conventions are handled correctly. Also reports what the same tokens would have cost with NO prompt caching at all, per model -- which is the figure that says whether caching is paying for itself. IMPORTANT: the model scenarios are a counterfactual, not a saving —…
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
filterModels | array | Restrict which turns are included, by model id -- the same scope filter other tools spell `models`. Named apart here because `models` already meant "price against these" on this tool. Use both togethe… |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
models | array | Deprecated spelling of targetModels. Still honoured. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
targetModels | array | Models to price the selected tokens AGAINST. Not a filter on which turns are included -- that is `filterModels`. Omit to compare every model the pricing table knows. A model with no price is omitted a… |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
cache_health Cache Health
Finds cache breaks in a session -- turns where the prompt-cache prefix was not reused, so the context was re-written at cache-write prices instead of read back cheaply. A break is a spike in cache writes AND a drop in cache reads; a write spike alone (e.g. reading one large file) is not one. Each break lists the turn, token counts, likely cause (model or speed switch, idle past the 5-minute TTL, or an early-context change such as an edited CLAUDE.md), and its API-equivalent write premium from the pricing table. Also returns the overall cache hit rate and reads-per-write.
| Parameter | Type | Description |
|---|---|---|
sessionId * | string | Session ID (full or unambiguous prefix) to analyze. |
baselineWindow | integer | Number of previous turns to average for the baseline. |
includeSubagents | boolean | Also analyze subagent/sidechain turns, baselined separately from main turns since they keep their own cache. Defaults to false. |
minCacheWrites | integer | Minimum absolute cache writes on a turn to consider (filters noise). |
spikeThreshold | number | Minimum spike ratio (current writes / rolling average) to flag as a break. |
usage_report Usage report
Where a period of usage went, how much of it did no new work, and what to change -- the first thing to run for "where are my tokens going" or "why do I hit my limit". Gives a verdict, the share of usage spent re-reading large contexts (every message re-sends the whole conversation) and rebuilding a lost prompt cache, the heaviest sessions by their own titles and git branches, usage per branch, and plain-language fixes. Shares are weighted by API-equivalent list price as a relative measure; on a subscription that figure is not money spent. Defaults to the last 7 days.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |
plan_usage Plan Usage
How much of the Claude Pro/Max 5-hour and weekly usage limits is used, as Claude Code itself last reported it, with when each window resets. Also the average pace within the window and the time it would reach 100% at that pace (a projection, labelled as one), and the tokens and API-equivalent cost of this machine's Claude Code turns since the window began. The percentages are recorded only while `ai-usage statusline` is configured as the Claude Code status line; without it they are reported as unavailable, never as 0%. Answers "how close am I to my limit" and "will I run out before it resets".
| Parameter | Type | Description |
|---|---|---|
includeSubagents | boolean | Count subagent turns in this machine's token figures. Defaults to true. Does not affect the percentages, which are Claude Code's own. |
recent_sessions Recent sessions
Most recently active sessions with project path, client, model(s), duration, token breakdown and cost. Use the returned session id with session_usage for detail.
| Parameter | Type | Description |
|---|---|---|
client | Restrict to these clients (a single id also works). | |
days | integer | Look back this many days, counted from local midnight. Omit for all time. |
includeSubagents | boolean | Include subagent turns. Default true: they are real spend. |
limit | integer | Rows to return. |
models | array | Restrict to these model ids, as recorded (see model_usage). |
offset | integer | Rows to skip; pass `nextOffset` from the previous result. |
projectPath | string | Deprecated: use projectPaths. |
projectPaths | array | Restrict to these projects: absolute working directories, matched exactly (see project_usage). A path matching nothing is reported, not answered as empty. |
since | string | ISO 8601 start of the period (inclusive). |
sort | string | Descending order. Reported and estimated cost are never summed, so there is no plain "cost": pick the basis you mean. |
today | boolean | Restrict to today, in local time. |
until | string | ISO 8601 end of the period (exclusive). |