@linimin/pi-headroom
Pi package that routes selected providers through local Headroom proxies with auto-start and status UI.
Package details
Install @linimin/pi-headroom from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@linimin/pi-headroom- Package
@linimin/pi-headroom- Version
0.1.0- Published
- Jun 20, 2026
- Downloads
- not available
- Author
- linimin
- License
- MIT
- Types
- extension
- Size
- 57 KB
- Dependencies
- 0 dependencies · 2 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
@linimin/pi-headroom
A pi extension that automatically routes supported pi providers through local Headroom proxies.
Quickstart
# 1) Install Headroom first
curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | bash
# 2) Install the pi package
pi install npm:@linimin/pi-headroom
Then open pi and run:
/reload
/model
/headroom-status
What this extension does
When you choose a supported provider in pi, this extension:
- overrides that provider's
baseUrlto a local Headroom proxy, - starts the proxy automatically if it is not already running,
- keeps the proxy running across pi sessions by default,
- reuses an already-running external Headroom proxy if one exists,
- shows proxy status in the pi footer,
- shows dashboard URLs and routing details in
/headroom-status.
The goal is simple:
install Headroom, install this pi package, then use supported providers in pi without manually starting proxies.
Prerequisite
You must install Headroom first.
This package does not install Headroom for you. It expects the headroom CLI to be available on PATH.
If Headroom is missing, the extension will:
- warn clearly,
- leave pi usable,
- and let unmanaged/default pi provider behavior continue.
Install
1. Install Headroom
See the Headroom install docs, or use the official installer for your platform.
Typical examples:
macOS
curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | "$(brew --prefix bash)/bin/bash"
Linux
curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | bash
Windows PowerShell
irm https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.ps1 | iex
2. Install the pi package
pi install npm:@linimin/pi-headroom
If pi is already running, reload extensions:
/reload
Enable / use
- Open pi
- Select a supported provider/model with
/model - Start using the model normally
The extension will auto-start the matching local Headroom proxy when needed.
Quick verification
Inside pi:
/headroom-status
You should see:
- the current managed provider,
- the current routed local base URL,
- the active dashboard URL,
- each managed provider's proxy state.
Supported providers
OpenAI-style routed through /v1
xaigithub-copilotopenaiopenrouterdeepseekgroqtogethercerebrasnvidiahuggingfaceant-lingmoonshotaimoonshotai-cnxiaomixiaomi-token-plan-cnxiaomi-token-plan-amsxiaomi-token-plan-sgp
Anthropic-style routed through root URL
anthropicfireworksminimaxminimax-cnkimi-codingmistral
Gemini / Vertex
googlegoogle-vertex
Default local ports
These are the preferred starting ports before fallback scanning:
xai→8787github-copilot→8788openai→8789anthropic→8790openrouter→8791deepseek→8792groq→8793together→8794mistral→8795fireworks→8796google→8797google-vertex→8798cerebras→8799nvidia→8800huggingface→8801ant-ling→8802moonshotai→8803moonshotai-cn→8804minimax→8805minimax-cn→8806xiaomi→8807xiaomi-token-plan-cn→8808xiaomi-token-plan-ams→8809xiaomi-token-plan-sgp→8810kimi-coding→8811
If a preferred port is occupied by a non-Headroom service, the extension scans for the next free fallback port and persists that route.
Commands
/headroom-status
Show:
- current provider,
- current model base URL,
- active dashboard URL,
- proxy map,
- managed/unmanaged behavior hints.
/headroom-stop [provider|all]
Stop extension-owned Headroom proxies.
/headroom-restart [provider|all]
Restart extension-owned Headroom proxies.
Footer status
The extension shows a lightweight status line in pi, for example:
Headroom:openai running/own | hist saved 33.0M | $83.3 | 36%
Important behavior
- Supported providers are routed through Headroom.
- Unsupported providers fall back to normal pi behavior.
- If Headroom is missing, the extension warns and does not block normal pi usage.
- By default, proxies are sticky: they keep running across pi sessions.
- Footer perf numbers prefer Headroom Historical Proxy Compression data (
/stats-historylifetime stats, with/statsfallback), so they survive proxy restarts better than per-process runtime counters. - GitHub Copilot keeps pi's built-in OAuth flow and re-routes the final base URL through Headroom.
Useful environment variables
Common ones:
PI_HEADROOM_BINPI_HEADROOM_HOSTPI_HEADROOM_AUTOSTARTPI_HEADROOM_SHUTDOWN_MODE(stickydefault,sessionoptional)PI_HEADROOM_VERBOSEPI_HEADROOM_PORT_SCAN_LIMITPI_HEADROOM_STATE_DIR
Each provider also has optional port/upstream overrides such as:
PI_HEADROOM_OPENAI_PORTPI_HEADROOM_OPENAI_UPSTREAMPI_HEADROOM_ANTHROPIC_PORTPI_HEADROOM_ANTHROPIC_UPSTREAMPI_HEADROOM_OPENROUTER_PORTPI_HEADROOM_OPENROUTER_UPSTREAM- etc.
Not covered yet
These pi providers still need more provider-specific handling and are not yet managed by this extension:
amazon-bedrockazure-openai-responsescloudflare-ai-gatewaycloudflare-workers-aivercel-ai-gatewayopenai-codexopencodeopencode-gozaizai-coding-cn
Package development
Local source layout:
index.ts— main supervisor logicprovider-registry.ts— provider registry and routing specs
Install locally during development:
pi install /absolute/path/to/pi-headroom