A pi extension that routes supported pi providers through local Headroom proxies.
# 1) Install Headroom first
curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | bash
# 2) Install this pi package
pi install npm:@linimin/pi-headroomThen open pi and run:
/reload
/model
/headroom-status
When you choose a supported provider in pi, the extension:
- overrides that provider's
baseUrlto a local Headroom proxy, - expects one canonical local port per provider,
- does not automatically start, stop, or restart proxies for you,
- does not attach to arbitrary fallback ports,
- shows proxy status in the pi footer,
- shows expected ports, URLs, and routing details in
/headroom-status.
The goal is simple: you manage Headroom yourself, and this package cleanly attaches pi to the expected local proxy.
pi-headroom is attach-only.
That means:
- you decide whether a proxy should be running,
- you can start Headroom yourself or use the explicit helper command
/headroom-start, - you stop Headroom yourself,
- this extension only checks whether the expected proxy is available and routes pi to it.
If the proxy is not running, the extension tells you which port and URL are expected.
You must install Headroom first. This package does not install Headroom for you. It expects the headroom CLI to be available on PATH if you want to start proxies with the CLI yourself.
If Headroom is missing or your proxy is not running, the extension will:
- warn clearly,
- leave pi otherwise usable,
- tell you which provider port should be started.
See the official Headroom install docs for your platform. Typical examples:
curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | "$(brew --prefix bash)/bin/bash"curl -fsSL https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.sh | bashirm https://raw.githubusercontent.com/chopratejas/headroom/main/scripts/install.ps1 | iexpi install npm:@linimin/pi-headroomIf pi is already running, reload extensions:
/reload
A sample docker-compose.yml is included in this package root if you want to run Headroom proxies with Docker. A matching .env.example is also included for upstream override values.
cp .env.example .envThen edit .env if you want to point a provider at a different upstream.
For github-copilot in Docker, prefer setting an explicit GITHUB_COPILOT_TOKEN or GITHUB_COPILOT_GITHUB_TOKEN in .env. Docker containers generally cannot reuse your host keychain/session auth the same way local host processes can.
For github-copilot on Business seats, prefer starting the proxy through /headroom-start github-copilot or otherwise ensure the proxy process has a current GITHUB_COPILOT_API_TOKEN. Reusing a host OAuth token through Headroom token exchange can downgrade the available model set for the proxy process.
- Open pi.
- Select a supported provider/model with
/model. - If you want traffic to go through Headroom, make sure the matching proxy is running on its expected local port.
- Start using the model normally.
If the proxy is not running, pi-headroom falls back to the provider default and tells you what to start if you want Headroom attached.
Inside pi:
/headroom-status
You should see:
- the current managed provider,
- the expected local proxy root URL,
- the expected routed base URL,
- the dashboard URL,
- whether the proxy is currently reachable,
- whether pi is currently attached to Headroom or falling back to the provider default.
xaigithub-copilotopenaiopenrouterdeepseekgroqtogethercerebrasnvidiahuggingfaceant-lingmoonshotaimoonshotai-cnxiaomixiaomi-token-plan-cnxiaomi-token-plan-amsxiaomi-token-plan-sgp
anthropicfireworksminimaxminimax-cnkimi-codingmistral
googlegoogle-vertex
Each provider has one canonical expected local port. If you override a provider port with environment variables, pi-headroom will expect that overridden port instead.
Default ports:
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 no provider is passed, it defaults to the provider of the currently selected model.
Shows:
- the current provider,
- the current model base URL,
- the expected local proxy root URL,
- the expected routed base URL,
- the dashboard URL,
- observed running/unavailable status.
This is the main diagnostic command in attach-only mode.
Start Headroom on the canonical configured port for that provider.
If no provider is passed, it defaults to the provider of the currently selected model.
This command:
- only uses the provider's configured port,
- does not choose fallback ports,
- reports an error if the canonical port is occupied,
- leaves stop/restart decisions to you.
The extension shows a lightweight status line in pi, for example:
Headroom:openai running | hist saved 33.0M | $83.3 | 36%
If the expected proxy is not running, you will see something like:
Headroom:github-copilot unavailable | /headroom-start github-copilot
- Supported providers are routed through Headroom.
- Unsupported providers fall back to normal pi behavior.
- The extension does not automatically manage proxy lifecycle.
- There is no automatic stop, restart, recovery, or fallback-port migration.
/headroom-startis an explicit user-triggered helper, not background lifecycle management.- One provider maps to one expected local proxy port.
- If the expected proxy is unavailable, the extension falls back to the provider default and tells you what should be running and where.
- Footer perf numbers prefer Headroom Historical Proxy Compression data (
/stats-historylifetime stats, with/statsfallback). - GitHub Copilot keeps pi's built-in OAuth flow and re-routes the final base URL through Headroom.
Common ones:
PI_HEADROOM_BINPI_HEADROOM_HOSTPI_HEADROOM_VERBOSEPI_HEADROOM_PROBE_TIMEOUT_MSPI_HEADROOM_HEALTH_TTL_MS
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.
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
Local source layout:
index.ts— main attach-only supervisor logicprovider-registry.ts— provider registry and routing specs
Install locally during development:
pi install /absolute/path/to/pi-headroom