Getting Started
You need Node.js 24 or newer and session data from at least one supported source. The CLI discovers standard source locations, so most first runs need no configuration.
1. Run the CLI
Section titled “1. Run the CLI”Try it without installing:
npx --yes llm-usage-metrics@latest dailyOr install the llm-usage command:
npm install -g llm-usage-metricsllm-usage dailyThe first run parses matching session files, stores normalized events in a local SQLite ledger, and loads pricing. Later runs can reuse unchanged files from the ledger.
2. Read the table
Section titled “2. Read the table”Each period contains one row per source. A combined row appears when the period includes more than one source, and the final ALL row totals the full range.
Token columns keep the buckets supplied by each source:
Input,Output, andReasoningCache ReadandCache WriteTotal, using the source adapter’s normalized total
Cost may come from the source or from LiteLLM pricing. A tilde, such as ~$4.82, marks a partial estimate. A dash means the CLI could not resolve cost for that row. See Pricing for the full rules.
3. Scope the result
Section titled “3. Scope the result”Use calendar ranges and filters to answer a narrower question:
# A calendar month in your reporting timezonellm-usage monthly --since 2026-06-01 --until 2026-06-30
# Only Codex and Claude Code sessionsllm-usage monthly --source codex,claude
# Sessions billed through OpenAIllm-usage monthly --provider openai
# A model name or substringllm-usage monthly --model codex--source describes where the event came from. --provider describes the billing entity behind the model. A Codex session can therefore have source=codex and provider=openai.
4. Choose a closer view
Section titled “4. Choose a closer view”# Compare the current local month with the previous monthllm-usage compare
# Rank conversations by costllm-usage session --top 10
# Chart the last 14 local daysllm-usage trends --metric tokens --days 14
# Group usage by repositoryllm-usage session --by-repoUse Compare for period changes, Session for conversation-level detail, and Trends for a daily series.
5. Save your defaults when you need them
Section titled “5. Save your defaults when you need them”llm-usage config initThe command writes a commented TOML file with the current defaults and a JSON Schema directive for editor validation. Common reasons to edit it include:
- your sessions live outside a tool’s default directory
- you want a fixed reporting timezone
- you prefer offline pricing or quieter diagnostics
CLI flags override environment variables, which override the config file. Configuration lists every key and its matching flag.
If the first report is empty
Section titled “If the first report is empty”Run the discovery probe:
llm-usage doctorDoctor reports the location and health of each source without parsing sessions or loading pricing. Probe one source or give it an explicit path when needed:
llm-usage doctor --source codexllm-usage doctor --source claude --claude-dir /path/to/.claude/projectsThe Data Sources pages list default locations and override flags. Troubleshooting covers parse failures, missing pricing, and event-store issues.
Export the result
Section titled “Export the result”llm-usage daily --jsonllm-usage daily --markdownllm-usage monthly --shareReport data goes to stdout; diagnostics stay on stderr. This separation keeps JSON and Markdown safe to redirect into a file or pipeline. Share support varies by report, so check Output Formats before adding --share to a specialized command.