Tps
Display request-level session and per-model TPS metrics in the OpenCode TUI sidebar.
0
81
11 in 7 days
29.6
Multi-signal model
1 month ago
2026-08-20
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": ["@nextzhou/opencode-tps@0.2.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@nextzhou/opencode-tps@0.2.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D @nextzhou/opencode-tpsOpenCode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
An OpenCode TUI plugin that displays request-level session and per-model tokens-per-second (TPS) metrics in the sidebar.
Features
- Weighted throughput across all model requests in the session
- Separate metrics by provider, model, and variant
- Output and reasoning token accounting
- Time to first token included
- Tool execution and inter-request waiting excluded
- Historical session estimates after restart
- No telemetry or network requests
Requirements
- OpenCode
>=1.18.0 <2
Installation
Install the plugin globally from npm:
opencode plugin @nextzhou/opencode-tps -g
Start or restart OpenCode, then press Ctrl+X, followed by lowercase b, to open the sidebar. This is the default sidebar_toggle keybinding and may differ if you customized tui.json.
Upgrade
Replace an existing installation with the latest published version:
opencode plugin @nextzhou/opencode-tps -g --force
Load a Local Checkout
For local development, add the project directory to the plugin array in your global tui.json:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["/absolute/path/to/opencode-tps"]
}
Metric
The plugin calculates weighted throughput by aggregating tokens and request durations. It never averages individual request TPS values:
TPS = sum(output tokens + reasoning tokens) / sum(model request durations)
A request duration begins at session.next.step.started and ends at the latest text, reasoning, or tool-input end event for that model request. This includes request startup and time to first token. Step completion and tool-result timestamps are deliberately not used, so tool execution and waiting between model requests are excluded.
When precise stream events are unavailable for an older message, the plugin estimates its request window from the assistant message creation timestamp through the final persisted text or reasoning part. Pure tool-call historical steps without those timestamps are omitted.
Development
Development requires Bun 1.3.14.
bun install --frozen-lockfile
bun run check
bun run pack:check
Individual commands:
bun run format
bun run lint
bun run typecheck
bun test
bun run build
Project Structure
src/tui.ts OpenCode event adapter and sidebar renderer
src/session-tps-state.ts Framework-independent TPS tracking and aggregation
tests/ Behavior tests
docs/requirements.md Product scope and metric contract
docs/releasing.md npm release process
License
Similar plugins
Token Metrics
opencode-token-metrics
Live tokens-per-second meter for the OpenCode TUI prompt.
Headsup
@banburist/opencode-headsup
Live inference telemetry pinned to the OpenCode 2 sidebar.
Oc Usage
@taraksh011/oc-usage
OpenCode plugin — live token usage, cost, and TPS display