npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

llm-usage

v0.1.0

Published

Pretty terminal usage summaries for Claude Code, Codex, and OpenRouter

Readme

llm-usage

npm version License: MIT node

See where your tokens actually go. One command, all providers.

llm-usage is a small CLI that reads local usage logs from Claude Code and Codex, then prints a clean terminal summary by model and provider.

If you have OPENROUTER_API_KEY set, it can also show a small OpenRouter account snapshot on the main command. That part is just /key + /credits, not per-model usage.

What You Get

  • model-level usage across Claude Code and Codex
  • provider totals
  • daily breakdowns
  • JSON output for scripting
  • a few useful filters

By default the main command shows:

  • provider
  • model
  • sessions
  • turns/messages
  • tokens in
  • tokens out
  • cached tokens
  • reasoning tokens where available
  • last seen

Claude <synthetic> rows are ignored.

Install

Global

npm install -g llm-usage
llm-usage --help

Run without installing

npx llm-usage --from 7d

Local development

git clone https://github.com/shan8851/llm-usage.git
cd llm-usage
npm install
npm run dev -- --from 7d

Quick Start

# Last 7 days, normal summary
llm-usage --from 7d

# Daily buckets
llm-usage daily --from 7d

# Model-focused view, sorted a different way
llm-usage models --from 30d --sort sessions

# Pipe-friendly single metric
llm-usage --from 7d --metric tokens_total --value-only

Commands

| Command | What it does | |---|---| | llm-usage or lu | Main summary: models, provider totals, and optional OpenRouter snapshot | | llm-usage daily | Usage grouped by local calendar day | | llm-usage models | Model table only | | llm-usage providers | Provider totals only |

Flags

Common flags:

  • --from <time> start time, like 7d, 24h, 30m, or an ISO timestamp
  • --to <time> end time, now or an ISO timestamp
  • --provider <providers> comma-separated provider filter, for example claude,codex
  • --model <substring> filter model names by substring
  • --json machine-friendly output
  • --config <path> custom config path

Main command and models:

  • --sort <field> one of tokens_out|tokens_in|sessions|turns|cached_tokens|reasoning_tokens|model

Main command only:

  • --metric <metric> one of tokens_total|tokens_in|tokens_out|sessions|turns|cached_tokens|reasoning_tokens|models
  • --value-only print only the metric value
  • --print-config-example print a sample config and exit

Use llm-usage --help for the full CLI help text.

More Examples

llm-usage --provider claude --model opus
llm-usage providers --from 30d
llm-usage models --provider codex --sort tokens_in
llm-usage daily --from 14d --provider codex
llm-usage --from 7d --json

Config

Default config path:

~/.config/llm-usage/config.toml

Print an example:

llm-usage --print-config-example

Example:

[paths]
claude = ["~/.claude/projects", "~/.config/claude/projects"]
codex = ["~/.codex/sessions"]

[openrouter]
enabled = true
baseUrl = "https://openrouter.ai/api/v1"
apiKeyEnv = "OPENROUTER_API_KEY"

Set the OpenRouter key if you want the snapshot block:

export OPENROUTER_API_KEY="..."

If OpenRouter is disabled in config or the API key is missing, the CLI just skips that block.

Data Notes

Claude

Reads local JSONL logs and pulls usage from:

  • input_tokens
  • output_tokens
  • cache_creation_input_tokens
  • cache_read_input_tokens

Codex

Reads cumulative token_count events and turns them into per-event deltas for:

  • input_tokens
  • cached_input_tokens
  • output_tokens
  • reasoning_output_tokens

Limits And Caveats

  • This is local-log based. If a provider does not write usable local logs, it is invisible here.
  • tokens_total means tokens_in + tokens_out. Cached and reasoning tokens are shown separately and are not included in that total.
  • Daily output uses your local calendar date, not UTC bucket boundaries.
  • OpenRouter support is account-level only right now. Public /key and /credits endpoints do not give model-by-model token breakdowns.

Contributing

PRs welcome. No formal process. Open an issue or PR and we can figure it out.

If you want to add another provider, the existing Claude and Codex parsers are the pattern: return normalized record objects and let the aggregation/rendering do the rest.

License

MIT