Repository navigation
[FEATURE]: Display token usage information in the TUI #13003
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
Currently, token usage information (input tokens, output tokens, remaining budget) is tracked internally but not visible to users in the OpenCode TUI. This makes it difficult for users to:
- Monitor costs in real-time during conversations
- Understand context window consumption
- Track usage against budget limits
- Make informed decisions about when to compact sessions
Proposed Solution
Display token usage information in the OpenCode TUI interface. Possible implementation approaches:
Option 1: Status Bar Display
Add token usage to the bottom status bar (similar to how file path or mode is displayed):
┌─────────────────────────────────────────────────┐
│ [Build Mode] Tokens: 19.9K/1M (980K remaining) │
└─────────────────────────────────────────────────┘
Option 2: New /usage or /tokens Command
Add a slash command that displays detailed token usage:
/usage
Current Session:
Input tokens: 12,450
Output tokens: 7,477
Cached tokens: 5,200
Total: 19,927 / 1,000,000
Remaining: 980,073 (98%)
Estimated cost: $0.05 (using claude-sonnet-4-5)
Option 3: Toggle-able Detail View
Add a keybind (e.g., ctrl+x t for tokens) to toggle token usage display in the conversation view, showing per-message token counts.
Option 4: Combination Approach
- Lightweight display in status bar for at-a-glance monitoring
- Detailed
/usagecommand for comprehensive breakdown - Optional per-message display via toggle
Benefits
- Cost Awareness: Users can monitor spending in real-time, especially important for pay-as-you-go models
- Budget Management: Helps users stay within monthly limits (especially relevant for OpenCode Zen users with spending caps)
- Context Window Management: Users can see when they're approaching token limits and need to compact
- Transparency: Makes the AI interaction more transparent and understandable
- Educational: Helps users learn which operations consume more tokens
Additional Context
The token usage data is already being tracked (visible in system messages on the backend), so this feature would primarily involve exposing existing data to the UI rather than implementing new tracking logic.
Related Features
- Ties into the existing
/compactcommand by helping users understand when compaction is needed - Complements OpenCode Zen's monthly usage limits feature
- Could integrate with the auto-compaction feature (
compaction.autoconfig)
Suggested Configuration
Allow users to customize this via config:
{
"tui": {
"show_token_usage": true,
"token_display_format": "compact"
}
}
Activity
github-actions commentedon Feb 10, 2026
This issue might be a duplicate of or closely related to existing feature requests. Please check these issues:
These all propose similar solutions for displaying token usage and cost information, with some variation in approach (command-based vs. status bar vs. visual stats). You may want to review how these align with your proposal and consolidate efforts if appropriate.
For keybind-related aspects (like Option 3's suggested
ctrl+x ttoggle), also check the pinned keybinds documentation: #4997chimon2000 commentedon Mar 12, 2026
I would find Option 4 extremely useful.
ke7in-zz commentedon Mar 15, 2026
Make the cli status customizable like claude code
feat(tui): add persistent token usage display in session footer
ForceConstant commentedon Apr 6, 2026
I would agree, option 4 would be great.
ThomasCarca commentedon Apr 14, 2026
This should probably rely on OTEL which is a feature being asked/discussed within the community and has yet to be fully supported.
eduardosanzb commentedon Apr 15, 2026
I think also would be amazing to show an estimate in how many tokens the current message im about to send will be.
this is because sometimes i paste logs and i would like to change model if i know i will trigger compactation (e.g. to mimo )
zhumengzhu commentedon Jun 10, 2026
Two sidebar plugins already cover most of these use cases today:
per-model pricing, slash commands for settings.
https://github.com/Hotakus/opencode-visual-cache
sub-agent rollup (child sessions), optional JSONL timeline export.
https://github.com/zhumengzhu/opencode-cache-hit
Both read from
api.state.session, so the data pipeline is already established —no new tracking logic needed on the OpenCode side.
VictorVow commentedon Jul 7, 2026
Seems to be implemented now as a Status Bar Display:
Xyz00777 commentedon Jul 9, 2026
no this shows only the current context size and when known the cost amount
liudongyan13701205717-source commentedon Aug 9, 2026
Free-tier / pay-as-you-go users need this visibility most, especially to decide when to compact. I'd also settle for the /usage command (Option 2) as the MVP.
Xyz00777 commentedon Aug 9, 2026
i think its easy to also provide than a toogle to also show it in the status bar or the bottom area. I think the hard part is to get the information in the first place from all the different provider.
But yeah i would also be happy if i could use /usage at lest and if it would than be exposed to some internal api at least, so i could let create a plugin to add it myself than.
liudongyan13701205717-source commentedon Aug 15, 2026
+1, displaying token usage in the TUI is very useful for cost tracking; still relevant.
angeloper86 commentedon Sep 10, 2026
hi! I built a small opencode TUI plugin: /context shows exactly how the built-in Context panel number is composed — input (no cache), output, reasoning, cache read/write, cache hit rate and cost — plus the session-wide total. When you delegate with task, it walks the child sessions and adds a Subagents block and a combined total (subagent usage is excluded from the parent's panel).
Zero runtime dependencies, never calls an LLM, exact numbers (no estimates). Install with opencode plugin opencode-context-usage (restart after). Repo: https://github.com/angeloper86/opencode-context-usage — feedback and issues welcome!
Blaze147 commentedon Sep 23, 2026
I just finished building this into the Context tab of the desktop app UI (still needs localization) on my fork and I'd like to submit it as a PR soon, but I built it as a frontend calculation and I'm now realizing the devs may wish to build it into the client backend/core instead.
Regardless, dumping a short screen-recording of how I laid out the UI in case it helps. I should also note that I renamed the "Context" tab to "Stats" since that's a more accurate description now.
I essentially decided to have two sets of token stats... one for the context and a second for the entire session. I overwhelmingly rely on the session stats and I have no idea why anyone would care about more than just total tokens used in the context and percentage used... but I don't see any point in removing those stats either. Maybe someone cares about the other stuff.
GIF:

neriousy commentedon Oct 1, 2026
The OpenCode v2 TUI shows token usage. The sidebar Context panel shows tokens, the percentage of the context window used, and cost. The prompt footer shows context usage too.
Added in #19347 and carried into v2 in #31049. A more detailed per-category breakdown (like Claude's
/context) is tracked in #6152.Closing as completed. If something doesn't work on v2, please open a new issue.