Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Setup Headroom (Context Compression Proxy) for 9Router ====== Documentation for installing and running **Headroom** (''headroom-ai'') as a local context compression proxy on port ''8787'' for **9Router** ===== 1. Install Python Virtual Environment Tools ===== Ensure ''python3-venv'' and ''python3-pip'' are installed (Python 3.10+ required): <code bash> sudo apt update && sudo apt install -y python3-venv python3-pip </code> **Verification:** <code bash> python3 --version </code> ---- ===== 2. Install headroom-ai with Compression Extras ===== Create a dedicated virtual environment and install ''headroom-ai'' with both ''proxy'' and ''ml'' extras (installing ''proxy'' alone will not perform meaningful compression): <code bash> sudo python3 -m venv /opt/headroom sudo /opt/headroom/bin/pip install --upgrade pip sudo /opt/headroom/bin/pip install "headroom-ai[proxy,ml]" </code> Create a symlink in ''/usr/local/bin'' so 9Router automatically detects the binary: <code bash> sudo ln -sf /opt/headroom/bin/headroom /usr/local/bin/headroom </code> **Verification:** <code bash> which headroom && headroom --version </code> Confirm the path resolves to ''/usr/local/bin/headroom''. ---- ===== 3. Create the systemd Service ===== Create a ''systemd'' unit file to run the Headroom proxy in the background on port ''8787'': <code bash> 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 </code> Reload ''systemd'', enable, and start the service: <code bash> sudo systemctl daemon-reload sudo systemctl enable --now headroom </code> **Verification:** <code bash> sudo systemctl status headroom curl -s http://localhost:8787/health </code> Ensure the service status is ''active (running)'' and ''/health'' returns a healthy response. ---- ===== 4. Enable Headroom in 9Router ===== - Restart 9Router so it detects the new ''headroom'' binary: <code bash> sudo systemctl restart 9router </code> - Open the 9Router dashboard (''http://<DEBIAN-IP>:20128'') and go to **Endpoint -> Token Saver -> Headroom**. - Verify the status changed from **Not installed** to **Running** (''http://localhost:8787''). - Toggle **Compress context (Headroom)** to **ON**. ---- ===== Day-to-Day Management ===== ^ 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'' | deployment/apps/headroom-ai.txt Last modified: 2026/11/25 22:41by ilyasa