OpenCode token usage: where it is stored and how to read it by model

OpenCode records tokens per model on your machine; a command shows a snapshot and a tracker keeps the trend.

By ClaudeGPT Si Newsroom, Editorial team··2 min read

OpenCode token usage is recorded on your own machine for every session, by model, and you can read it two ways: with OpenCode's opencode stats command, or in UsageAtlas, a free and open-source desktop dashboard that turns those records into daily totals, model share and history. The number worth watching is tokens per model, because providers bill by the token and by the model.

What gets counted

Every time OpenCode sends a request to a model, the provider returns a count of tokens used. OpenCode keeps that count, together with the model name, the session and the project, in a local database. You can print where that database lives with opencode db path.

Three things follow from that design:

  • The data is local. Nothing has to be fetched from a vendor to see your token usage.
  • It is per model, not per provider account. If you switch models mid-week, the record shows the switch.
  • It covers OpenCode only. Requests from other apps that share the same API key are not in it.

Reading token usage by model

The model breakdown is where token usage becomes useful. Two sessions of similar length can use very different amounts depending on the model and how much context it was given.

OpenCode's CLI reference lists the flags that matter here:

Flag What it does
--models Adds a per-model breakdown, which is hidden by default
--models 5 Shows only the top five models
--days 30 Limits stats to the last 30 days
--project Filters to one project; an empty string means the current one

Run opencode stats --models --days 7 once a week and you will see which model carried most of the work.

Turning token counts into a trend

A command gives a snapshot. A trend needs the same numbers kept over time, which is where a tracker helps.

UsageAtlas reads the OpenCode database on the same computer and shows tokens, requests, models and sessions in three views. Today covers the current day. History keeps each day, so a heavy week stands out. Insights shows model share and the time-of-day and weekday pattern of your work. A filter limits it to OpenCode, or you can leave other supported tools such as Claude Code, Codex and Cursor in the total.

It also converts tokens into an estimated cost from model pricing, and labels it as an estimate. If OpenCode itself reports a cost, that figure is used.

Tokens vs cost

Tokens are the exact part. Cost is derived, and it can drift from your bill for reasons outside any tracker:

  • cached input is often priced differently from fresh input;
  • the same model can be priced differently by different providers;
  • invoices arrive after the work is done.

So use token counts to compare models and weeks, and use each provider's billing page when you need the precise amount.

Getting the numbers on any system

UsageAtlas has builds for Windows, macOS and Linux, and reads OpenCode data where it already lives on that machine. No account is required for local tracking, and it does not read prompts or responses. An optional free sign-in saves usage summaries for restoring on another computer.

If you only need a total now and then, opencode stats is enough on its own. If you want to watch token usage by model over weeks, or next to other coding tools, the free UsageAtlas download is the simpler route.