OpenCode

How to see OpenCode usage

How to see OpenCode usage on your computer: tokens, requests, models, and sessions from the local OpenCode database, in a UsageAtlas dashboard.

Quick answer

OpenCode records token counts on each assistant message in its local data directory, usually `~/.local/share/opencode` on macOS and Linux and `%APPDATA%\opencode` on Windows. Recent versions use a SQLite database; older ones use JSON files under `storage/`. UsageAtlas reads that data and shows tokens by session, model, and day.

What OpenCode records

FieldMeaningUse
Input tokensContext sent with the messageMeasures context size
Output tokensTokens generatedMeasures answer length
Cache readPrompt cache reusedShows discount potential
Cache writeContext written to cacheFirst-turn cost
CostProvider-reported or computed costPer-message spend
ModelProvider and model IDPer-model split

Because OpenCode talks to many providers, the fields available depend on what the provider returns. A missing cost field means the provider did not report one, not that the request was free.

Three views that answer different questions

  • Per session: which run was expensive, and why.
  • Per model: whether a cheap model is actually cheaper per completed task.
  • Per day: whether usage is trending up before a bill arrives.

UsageAtlas provides all three from the same local database. It keeps 7, 30, or 90-day windows and needs no account for local tracking.

What local usage cannot tell you

OpenCode is a client. It knows what it sent and what the provider reported. It does not know your remaining balance with a provider, your plan window, or a rate limit that applies account-wide.

For provider limits, connect the provider where UsageAtlas supports it, or check that provider's dashboard. The OpenCode limit reset guide explains which limits are local and which are not.

Where OpenCode keeps the numbers

OpenCode records every session in a local database: messages, model IDs, token counts, and timestamps. There is no vendor dashboard behind it, so that file is the record. Anything you cannot see in the TUI is still in the database.

ViewShowsLifetime
TUI statusCurrent session and modelUntil you exit
DatabaseEvery session and token countUntil you delete it
UsageAtlasTotals by day, model, project7, 30, or 90 days
Provider consoleOnly provider-billed usageVaries

The database location guide has the platform paths, and session history explains what each record contains.

Questions, answered

Does OpenCode track token usage automatically?

Yes. Token counts are written with each assistant message as part of the session record. You do not need to enable anything.

Where does OpenCode store usage data?

In its local data directory, typically ~/.local/share/opencode on macOS and Linux and %APPDATA%\opencode on Windows. The exact file depends on the version.

Can I see OpenCode usage without a third-party app?

Yes, with the CLI stats command where available, or by querying the local database. A tracker is only a convenience layer.

Browse by topic