Documentation for installing and running Headroom (headroom-ai) as a local context compression proxy on port 8787 for 9Router
Ensure python3-venv and python3-pip are installed (Python 3.10+ required):
sudo apt update && sudo apt install -y python3-venv python3-pip
Verification:
python3 --version
Create a dedicated virtual environment and install headroom-ai with both proxy and ml extras (installing proxy alone will not perform meaningful compression):
sudo python3 -m venv /opt/headroom sudo /opt/headroom/bin/pip install --upgrade pip sudo /opt/headroom/bin/pip install "headroom-ai[proxy,ml]"
Create a symlink in /usr/local/bin so 9Router automatically detects the binary:
sudo ln -sf /opt/headroom/bin/headroom /usr/local/bin/headroom
Verification:
which headroom && headroom --version
Confirm the path resolves to /usr/local/bin/headroom.
Create a systemd unit file to run the Headroom proxy in the background on port 8787:
sudo tee /etc/systemd/system/headroom.service > /dev/null <<EOF [Unit] Description=Headroom Context Compression Proxy After=network-online.target Wants=network-online.target [Service] Type=simple User=root ExecStart=/opt/headroom/bin/headroom proxy --port 8787 Restart=always RestartSec=5 [Install] WantedBy=multi-user.target EOF
Reload systemd, enable, and start the service:
sudo systemctl daemon-reload sudo systemctl enable --now headroom
Verification:
sudo systemctl status headroom curl -s http://localhost:8787/health
Ensure the service status is active (running) and /health returns a healthy response.
headroom binary: sudo systemctl restart 9router
http://<DEBIAN-IP>:20128) and go to Endpoint → Token Saver → Headroom.http://localhost:8787).| Task | Command |
|---|---|
| View live compression logs | journalctl -u headroom -f |
| Check service status | sudo systemctl status headroom |
| Restart Headroom | sudo systemctl restart headroom |
| Update Headroom | sudo /opt/headroom/bin/pip install -U “headroom-ai[proxy,ml]” && sudo systemctl restart headroom |