Skip to content

Documentation

llm-usage-metrics reads session data created by supported AI coding tools and converts it into one normalized usage history. You can review token volume, estimate cost, find expensive sessions, compare periods, and export the results. The CLI parses session content on your machine.

Terminal window
npx --yes llm-usage-metrics@latest

The command prints cost and tokens for today, the last 7 days, and month to date. It discovers supported sources in their default locations. Use llm-usage doctor if the report finds no data, or create a config file when your sessions live elsewhere.

Terminal window
llm-usage doctor
llm-usage config init

The report chooser maps each question to a command, its default window and its guide. A few starting points:

  • llm-usage daily, weekly and monthly for tokens and cost over time.
  • llm-usage projects and llm-usage session for what cost the most.
  • llm-usage tools and llm-usage context for what your agents did and how large their prompts grew.
  • llm-usage compare and llm-usage trends for how usage changes between periods.
  • llm-usage doctor when a source shows no data.

Add --share to summary, daily, weekly, monthly, compare, trends, wrapped, efficiency or optimize to write an interactive HTML report you can filter by source, model, project and machine.

Source adapters normalize input, output, reasoning, cache read, and cache write tokens at the file boundary. The pricing engine keeps an explicit source cost when one exists. Otherwise, it estimates cost from LiteLLM pricing.

Reports show the difference:

  • $12.34 means every contributing event has a resolved cost.
  • ~$12.34 means the known cost is partial.
  • - means the CLI could not price any contributing event.

The bundled pricing snapshot lets the first report run offline. An online run may refresh the pricing cache from LiteLLM. Pricing requests never include session content.

The CLI reads local session files and local Git history. It writes its event ledger under your platform data directory and its caches under your platform cache directory. Two optional network requests remain separate from your usage data:

  • a cached npm version check at startup
  • a LiteLLM pricing refresh when the pricing cache is stale

Use --pricing-offline and LLM_USAGE_SKIP_UPDATE_CHECK=1 when you want a report with no network requests.

If you add other machines, the CLI also uses your ssh to fetch their usage events. See Privacy for every network request.