Track OpenCode Token Usage & Costs
SuperBased reads OpenCode's local SQLite session database (opencode.db) for message and token data. Track OpenCode token usage locally with SuperBased.SuperBased tracks OpenCode token usage and cost on your own machine. SuperBased reads OpenCode's local SQLite session database (opencode.db) for message and token data, and can route a launched session through the proxy for exact provider counts via OPENAI_BASE_URL. No account, no telemetry, no data leaves your laptop - SuperBased is a single open-source binary that also covers 39 other AI coding tools.
How SuperBased captures OpenCode
- Where the data lives - SuperBased reads OpenCode's sessions from its local SQLite database
opencode.db(message and part tables). - Token accuracy: Local logs, or proxy-exact when routed - By default SuperBased reads token counts from OpenCode's own local logs - the counts the tool itself recorded. Launch it with
observer opencodeto route through the proxy and the counts become exact, straight from the provider. - Proxy routing - Launch
observer opencodeto route OpenCode through the proxy for exact, provider-reported counts; otherwise capture stays on the local files above. - MCP - SuperBased can register its MCP server into OpenCode, so you can query your own session history and costs from inside the tool.
2-minute quickstart
Install SuperBased and start the local daemon (it auto-registers hooks for every AI tool it detects):
npm install -g @superbased/observer # or: pip install superbased-observer
observer start
For exact, provider-reported tokens, launch OpenCode routed through the proxy:
observer opencode
Verify capture at any time:
observer doctor opencode
What you'll see

- Cost breakdown - per-session and per-day spend for OpenCode, priced from SuperBased's built-in model pricing table.
- Session history - every OpenCode session with its model, duration, and token totals, searchable on the local dashboard.
- Cache analytics - prompt-cache read/write splits and cache savings when OpenCode is routed through the proxy.
- Local dashboard - everything is viewable at
http://localhost:8080; nothing is uploaded.
Limitations for OpenCode
- Counts come from OpenCode's own logs, so they are the tool's self-reported totals - accurate to what OpenCode recorded, but not provider-verified unless you route through the proxy.
- SuperBased captures on write, so an in-progress OpenCode session appears only once the tool next flushes it to disk.
- If you route through the proxy, keep the SuperBased daemon running for the whole session - the tool is pointed at it.
- Conversation compression is off by default; token and cost tracking work without it.
FAQ
Is my OpenCode data sent anywhere?
No. SuperBased runs entirely on your machine - it reads OpenCode's local session files (and, if you opt in, proxies your API traffic through localhost). Nothing is uploaded, there is no account, and there is no telemetry.
How accurate are the token counts?
By default SuperBased reads token counts from OpenCode's own local logs - the counts the tool itself recorded. Launch it with observer opencode to route through the proxy and the counts become exact, straight from the provider.
Do I have to change how I run OpenCode?
Only if you want exact proxy counts - then launch with observer opencode. Otherwise run observer start once and use OpenCode normally; the watcher captures every session automatically.
Does it track cache and reasoning tokens?
SuperBased captures whatever OpenCode records locally, and prices it with the built-in pricing table.
Where does SuperBased read OpenCode data from?
SuperBased reads OpenCode's sessions from its local SQLite database opencode.db (message and part tables) - all on your own machine. Launch observer opencode to route OpenCode through the proxy for exact, provider-reported counts; otherwise capture stays on the local files above.