---
title: "Deploy Headroom"
description: "LLM proxy that compresses agent context to cut tokens, with a locked URL"
category: "AI/ML"
url: https://railway.com/deploy/headroom-1
---

# Deploy Headroom

LLM proxy that compresses agent context to cut tokens, with a locked URL

**[Deploy Headroom on Railway](https://railway.com/template/headroom-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/headroom-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** AI/ML

## Template content

### Headroom https://raw.githubusercontent.com/headroomlabs-ai/headroom/v0.45.0/docs/public/assets/headroom-logomark.svg

- **Source:** https://github.com/aalfath/headroom-railway-template
- **Health check:** /readyz
- **Public domain:** Yes

## Documentation

# Deploy and Host Headroom on Railway

Headroom is an open-source LLM proxy that compresses what your agent sends to the model. Tool outputs, logs, JSON, search results and code are shrunk before they reach Anthropic, OpenAI or any OpenAI-compatible API, so coding agents such as Claude Code and Codex use fewer tokens per request.

## About Hosting Headroom

This template runs Headroom 0.45.0 as one public service built from a GitHub repo, from the official image pinned by digest. A generated proxy token locks the endpoint on the first deploy: requests without it get 401, so the URL is never an open relay. Your provider key isn't stored on the server. Clients keep sending their own key or subscription login and Headroom forwards it. A volume keeps the compression cache, savings history and model cache across restarts and redeploys. The health check is `/readyz`, and the service is usually healthy about a minute after the build.

## Common Use Cases

* Put Claude Code, Codex or another coding agent behind one compression proxy to cut token use on long sessions
* Shrink large JSON, log and RAG tool results in your own app with a base-URL change
* Run a compression sidecar for LiteLLM or an API gateway through `POST /v1/compress`

## Dependencies for Headroom Hosting

* An API key or subscription for your LLM provider (Anthropic, OpenAI or an OpenAI-compatible service), sent by your client
* A Railway volume for state (created by the template)

### Deployment Dependencies

* Headroom source and docs: https://github.com/headroomlabs-ai/headroom
* Release 0.45.0: https://github.com/headroomlabs-ai/headroom/releases/tag/v0.45.0
* Template repo (Dockerfile, start script, changelog): https://github.com/aalfath/headroom-railway-template

### Implementation Details

**What you get:** one service, `Headroom`, with a public domain and a volume at `/home/nonroot/.headroom`. There's nothing to fill in at deploy time.

**After deploy:** open the service's Variables tab and copy `HEADROOM_PROXY_TOKEN`. Clients send it in the `X-Headroom-Proxy-Token` header, which leaves `Authorization` for your provider key:

```bash
# Claude Code
export ANTHROPIC_BASE_URL=https://YOUR-DOMAIN.up.railway.app
export ANTHROPIC_CUSTOM_HEADERS="X-Headroom-Proxy-Token: YOUR-TOKEN"
claude

# OpenAI-compatible SDKs: base URL https://YOUR-DOMAIN.up.railway.app/v1
# plus the default header X-Headroom-Proxy-Token: YOUR-TOKEN
```

**Memory:** the proxy uses about 300–400 MB, so it runs on Railway's Free and Trial plans (0.5 GB) with rule-based compression (JSON, logs, code, diffs). Headroom's Kompress ML compressor needs about 550 MB more. The start script turns it on only when the service's memory limit is 1.5 GB or more, and downloads its model (about 260 MB) once to the volume.

**Optional settings:** `OPENAI_TARGET_API_URL` or `ANTHROPIC_TARGET_API_URL` send traffic to another compatible endpoint. `HEADROOM_BEACON=on` turns upstream's anonymous usage beacon back on (it's off in this template). The `/dashboard` page and `/stats` need the token header too, so a plain browser visit shows 401, and the settings editor answers only on localhost.

**Updates:** the service builds from the template repo. When a new Headroom release has been tested, the pinned version is bumped there and Railway shows an "update available" notice in your project. Read the repo's `CHANGELOG.md` before you apply it. Your data on the volume is kept.

## Why Deploy Headroom on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Headroom on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.



## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/headroom-1
