OpenCode token usage
OpenCode token usage is not shown in a single web dashboard like Cursor. You measure it with the CLI (opencode stats), the TUI context bar, and your provider’s billing console.
This page answers opencode stats, opencode token usage, and “why doesn’t my stats match my bill?”
Hub: Tokenminning in OpenCode.
opencode stats
opencode stats
opencode stats --models
opencode stats --days 7| Flag | Output |
|---|---|
| (default) | Token and cost totals across sessions |
--models | Which models consumed the most |
--days N | Windowed burn (e.g. last week) |
Source: OpenCode CLI .
opencode stats is local telemetry — useful for trends and model mix. Provider dashboards (Anthropic, OpenAI, OpenRouter, OpenCode Zen) are billing truth.
What each turn sends
| Component | Metered as | Bloat signal |
|---|---|---|
Prompt + @ files | Input | Huge attachments |
AGENTS.md, instructions | Input | Duplicated style guides |
| MCP tool schemas | Input | Disable unused MCP |
| Session transcript + tool outputs | Input | Long context |
| Model reply + tool args | Output | Thinking models, long diffs |
| Compaction / summary agents | Input + output | Session never ends |
OpenCode does not apply Cursor-style cache-read discounts unless your provider supports prefix caching on the model you configured.
Diagnose input-heavy vs output-heavy
After a heavy week, check whether spend is input or output:
| Pattern | Likely cause | Next step |
|---|---|---|
| Input dominates | Rules, MCP, long sessions | Context, MCP, trim AGENTS.md |
| Output dominates | Frontier on Plan, thinking models, loops | Reasoning effort, cheaper Plan model, agent.build.steps |
| Both spike after one change | New MCP server or skill | Disable and compare stats |
Reconcile stats with provider bills
- Run
opencode stats --days 7after a heavy week. - Open the provider dashboard for the same window.
- If stats < bill: missing sessions (another machine), subagents, or hidden compaction calls.
- If stats > bill: stale local cache — still directionally useful for model mix.
Tag production features separately if customer APIs dominate spend — IDE trimming does not fix those loops. See Article I.
Live guardrail: context percentage
The TUI session sidebar shows context fill % for the active session — complementary to opencode stats. See Context.
Spending guardrails
OpenCode does not enforce your inference budget:
- Provider-side spending caps in Anthropic/OpenAI/Zen dashboards
agent.*.stepsto stop runaway Build loops- Disable MCP and reasoning variants you do not need
- Plan/Build split per hub routing table