OpenCode cost and token usage, per project
OpenCode keeps every session in a local SQLite database, including the cost it settled for the session. The AgentsTrack collector reads that database and keeps the reported figure apart from anything we had to estimate.
Where the numbers come from
~/.local/share/opencode/opencode.db, or the same path under$XDG_DATA_HOME.OPENCODE_DBis honoured, and a release-channel database such asopencode-dev.dbis used when the plain file is missing.- The database is live, so it is opened read-only with short queries and a busy timeout. The collector cannot write to it or migrate it.
- Sessions, prompts and tool calls come from the same database. Tool output is never read.
- A session started by another session keeps its parent, so delegated work stays attached to it.
What is counted
- Input, output, reasoning, cache read and cache write tokens, as OpenCode stores them on the session.
- The session row holds running totals. They are treated as a gauge, so reading the database twice never counts the same tokens twice.
- The provider comes from each session, so sessions on different providers stay apart.
Reported or estimated cost
- When OpenCode has stored a cost above zero for the session, that figure is shown as REPORTED. We pass it through and do not reprice it.
- When the stored cost is zero, the tokens are priced at published list rates and labelled ESTIMATED.
- A model with no rate entry reports zero rather than a guess.
- See cost basis for what each label promises.
OpenCode stats or AgentsTrack
- For one machine,
opencode stats --costalready prints cost and tokens, and--modelssplits them by model. If that answers the question, use it. - AgentsTrack adds the same view across machines and next to Claude Code cost and Codex usage, with the basis on every figure.
What leaves your machine
- Redaction runs on your machine before anything is queued for upload.
- What travels depends on your privacy mode. The default adds a title, usually your prompt’s first line, and secret-redacted commands;
metadatasends counts, timings and identifiers, with file paths and repository names. The full table is in what your admin can see.
Read on
See what your OpenCode sessions cost
14 days of Pro, no card. Three commands, and your first session lands in the dashboard.