Skip to Content
IDEsOpenCodeToken usage

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
FlagOutput
(default)Token and cost totals across sessions
--modelsWhich models consumed the most
--days NWindowed 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

ComponentMetered asBloat signal
Prompt + @ filesInputHuge attachments
AGENTS.md, instructionsInputDuplicated style guides
MCP tool schemasInputDisable unused MCP
Session transcript + tool outputsInputLong context
Model reply + tool argsOutputThinking models, long diffs
Compaction / summary agentsInput + outputSession 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:

PatternLikely causeNext step
Input dominatesRules, MCP, long sessionsContext, MCP, trim AGENTS.md
Output dominatesFrontier on Plan, thinking models, loopsReasoning effort, cheaper Plan model, agent.build.steps
Both spike after one changeNew MCP server or skillDisable and compare stats

Reconcile stats with provider bills

  1. Run opencode stats --days 7 after a heavy week.
  2. Open the provider dashboard for the same window.
  3. If stats < bill: missing sessions (another machine), subagents, or hidden compaction calls.
  4. 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.*.steps to stop runaway Build loops
  • Disable MCP and reasoning variants you do not need
  • Plan/Build split per hub routing table
Last updated on