Tps
Real-time AI generation speed and token throughput monitor for OpenCode
0
349
11 in 7 days
34.8
Multi-signal model
21 days ago
2026-09-14
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-tps-plugin@0.1.1"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-tps-plugin@0.1.1"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-tps-pluginOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
Real-time AI generation speed and token throughput monitor for OpenCode. Displays live tokens-per-second (TPS) metrics directly in the OpenCode TUI status bar while the model generates output.
Screenshot

Illustrative output from an OpenCode session; values vary by model and session.
Features
- Real-time TPS display — instant speed, rolling average, token count, and elapsed time in the prompt status bar
- Color-coded speed indicators — green (fast), yellow (medium), red (slow) based on configurable thresholds
- Tool execution awareness — shows "TOOL" indicator during tool calls, automatically deducts tool wait time from generation speed calculation
- Sub-agent tracking — traces parent-child session relationships and rolls up metrics to root session
- EMA smoothing — exponential moving average with adaptive half-life to suppress noisy spikes
- CJK-aware token estimation — treats each CJK character as 1 token for more accurate counting
- Multiple estimation algorithms —
general(chars/4),program(chars/3),prose(words/0.75) - Flexible configuration — JSON config files, environment variables, or code overrides
Installation
npm install opencode-tps-plugin
Add the plugin to your tui.json:
{
"plugin": [
// ... your existing plugins
"opencode-tps-plugin"
]
}
How It Works
The plugin renders a ThroughputGauge component in the session_prompt_right slot using SolidJS. It listens to message.part.delta, message.part.updated, message.updated, and session.idle events to track token generation in real time, showing live TPS, average speed, total tokens, and elapsed time with color theming.
Configuration
Configuration is resolved in the following priority order (highest wins):
- Code overrides (passed programmatically)
- Environment variables (
TPS_PLUGIN_*) - User config:
~/.config/opencode/tps-plugin.json - Project config:
.opencode/tps-plugin.json - Built-in defaults
Note: display toggles (
showAvg,showRate,showTokens,showTimer) are JSON/defaults only and have no environment variable override.
Config File Example
{
"enabled": true,
"refreshIntervalMs": 50,
"samplingWindowMs": 1000,
"showAvg": true,
"showRate": true,
"showTokens": true,
"showTimer": true,
"tokenMode": "general",
"useColors": true,
"slowRate": 10,
"fastRate": 50
}
Environment Variables
| Variable | Description | Default |
|---|---|---|
TPS_PLUGIN_ENABLED |
Enable/disable the plugin | true |
TPS_PLUGIN_REFRESH_INTERVAL_MS |
Minimum ms between UI updates | 50 |
TPS_PLUGIN_SAMPLING_WINDOW_MS |
Sliding window for speed calculation | 1000 |
TPS_PLUGIN_TOKEN_MODE |
Token estimation mode (general, program, prose) |
general |
TPS_PLUGIN_USE_COLORS |
Enable speed-based color coding | true |
TPS_PLUGIN_SLOW_RATE |
TPS below this is red | 10 |
TPS_PLUGIN_FAST_RATE |
TPS above this is green | 50 |
Requirements
- OpenCode
>=1.15.13 - Node.js 18+
Development
# Install dependencies
bun install
# Type check
bun run typecheck
# Build
bun run build
License
Similar plugins
Token Metrics
opencode-token-metrics
Live tokens-per-second meter for the OpenCode TUI prompt.
Sidebar Token Metrics
opencode-sidebar-token-metrics
OpenCode sidebar plugin showing generation speed (tok/s), cache hit rate, and average time-to-first-token (TTFT).
Oc Usage
@taraksh011/oc-usage
OpenCode plugin — live token usage, cost, and TPS display