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

opencode-usage

v0.4.8

Published

CLI tool for tracking OpenCode AI coding assistant usage and costs

Readme

opencode-usage

CLI tool for tracking OpenCode AI coding assistant usage and costs.

Features

  • Daily or monthly usage breakdown with token counts and estimated costs
  • Provider breakdown (Anthropic, OpenAI, Google, etc.)
  • Filter by provider, date range, or relative time
  • Watch mode for live monitoring
  • JSON output for scripting and automation
  • Model pricing for accurate cost estimation
  • Terminal table output

Installation

# Run directly with bunx (recommended, fastest)
bunx opencode-usage

# Or with npx (Node.js fallback)
npx opencode-usage

# Or install globally
bun add -g opencode-usage
npm install -g opencode-usage

Usage

# Show all usage data (daily breakdown)
opencode-usage

# Filter by provider
opencode-usage --provider anthropic
opencode-usage -p openai

# Show last N days
opencode-usage --days 30
opencode-usage -d 7

# Date range filtering
opencode-usage --since 20251201 --until 20251231
opencode-usage --since 2025-12-01
opencode-usage --since 7d      # last 7 days
opencode-usage --since 1w      # last week
opencode-usage --since 1m      # last month

# Monthly aggregation
opencode-usage --monthly
opencode-usage -m --since 2025-01-01

# JSON output (for scripting)
opencode-usage --json
opencode-usage --monthly --json > usage.json

# Watch mode (live refresh every 5s)
opencode-usage --watch
opencode-usage -w -d 1

# Combine filters
opencode-usage --provider anthropic --since 7d --json

Output

┌────────────┬───────────────────────────────────┬────────────────┬──────────────┬────────────────┬────────────┐
│ Date       │ Models                            │          Input │       Output │   Total Tokens │       Cost │
├────────────┼───────────────────────────────────┼────────────────┼──────────────┼────────────────┼────────────┤
│ 2025-12-30 │ - claude-opus-4-5                 │    173,440,372 │      691,955 │    174,132,327 │    $167.42 │
│            │ - claude-sonnet-4-5               │                │              │                │            │
│            │   [anthropic]                     │    161,029,288 │      618,355 │    161,647,643 │    $162.06 │
│            │   [openai]                        │      7,109,638 │       56,201 │      7,165,839 │      $5.36 │
├────────────┼───────────────────────────────────┼────────────────┼──────────────┼────────────────┼────────────┤
│ Total      │                                   │    395,521,798 │    1,617,158 │    397,138,956 │    $417.81 │
└────────────┴───────────────────────────────────┴────────────────┴──────────────┴────────────────┴────────────┘

Supported Providers

  • Anthropic: Claude Opus, Sonnet, Haiku (all versions)
  • OpenAI: GPT-4o, GPT-5, O1, O3
  • Google: Gemini 2.0, 2.5, 3.0
  • OpenCode hosted: Free models (qwen3-coder, glm-4.7-free, etc.)

How It Works

This tool reads OpenCode session data from the SQLite database (opencode.db):

  • Linux: ~/.local/share/opencode/opencode.db
  • macOS: ~/.local/share/opencode/opencode.db
  • Windows: %LOCALAPPDATA%/opencode/opencode.db

Requires OpenCode v1.2.0+ (SQLite storage). It aggregates token usage by day and calculates estimated costs based on current API pricing.

Note on Costs

If you're using OpenCode with a Claude Max/Pro subscription or OpenCode Zen credits, the actual cost to you is your subscription fee, not the API-equivalent cost shown here. The cost column shows what the equivalent API usage would cost for reference.

License

MIT