pi-tokometer

A live token-speed meter for the Pi coding agent footer.

Packages

Package details

extension

Install pi-tokometer from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-tokometer
Package
pi-tokometer
Version
0.2.0
Published
Sep 2, 2026
Downloads
436/mo · 33/wk
Author
harrykwokdev
License
MIT
Types
extension
Size
19.6 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-tokometer

A live token-speed meter for the Pi coding agent.

Pi + token + speedometer = Tokometer.

Pi Tokometer adds decode throughput and time-to-first-token readings such as ↯12.3tok/s TTFT1.2s to Pi's footer while preserving the footer's existing session, usage, context, model, and Git information.

Features

  • Updates decode speed while an assistant response is streaming when the provider supplies cumulative usage
  • Separates generation throughput from time to first token (TTFT)
  • Aggregates multi-step tool turns by tokens and decode time, rather than averaging per-request rates
  • Restores the latest turn's metrics when a session is resumed, reloaded, or its branch changes
  • Preserves Pi's standard footer information
  • Uses no third-party runtime dependencies

Token speed is calculated as provider-reported output tokens divided by the monotonic-clock interval between the first and last non-empty text, thinking, or tool-call delta. Tokometer stores the resulting decode duration and TTFT beside the finalized assistant message, so the same reading survives reloads and branch changes. If a provider supplies its own duration and ttft, duration - ttft remains a compatibility fallback. Samples below 50 ms are ignored, and live updates are limited to four per second to keep rendering lightweight.

For a turn containing multiple model requests, Tokometer uses the weighted aggregate sum(output tokens) / sum(decode time). It never averages the individual request rates. Streaming speed is a running average, not an instantaneous rate; providers that report usage only at completion produce their first accurate reading at completion.

Install

pi install npm:pi-tokometer

Try it without installing:

pi -e npm:pi-tokometer

Restart Pi after installation, or run /reload from an existing session.

Compatibility

Pi Tokometer is designed for the interactive TUI. The extension still loads in print, JSON, and RPC modes, but it only installs its footer in TUI mode.

Because Pi currently exposes custom footers as replacements, Pi Tokometer recreates the standard footer and adds the speed reading. Only one custom-footer extension should be enabled at a time.

Display

The added metric looks like:

↯24.8tok/s TTFT1.2s

The current turn's speed remains visible until the next response has enough data for a stable replacement. TTFT is the first measurable model request in that turn.

Development

Clone the repository and load it directly:

git clone https://github.com/harrykwokdev/pi-tokometer.git
cd pi-tokometer
pi -e .

Validate the npm package contents:

npm run check

中文说明

Pi Tokometer 为 Pi 的状态栏增加解码速度与首 Token 延迟,例如 ↯24.8tok/s TTFT1.2s。速度按“提供方上报的输出 Token ÷ 首 Token 后的生成时长”计算;包含多次模型调用的工具回合使用 Token 与解码时长的加权聚合。插件会保留 Pi 原有的会话、用量、上下文、模型和 Git 信息。由于 Pi 的自定义 Footer API 是替换式的,建议不要同时启用其他自定义 Footer 插件。

License

MIT