Skip to main content
Headroom is a content-aware context compression engine. Portkey’s Headroom guardrail sends the request’s messages to a Headroom proxy, swaps in the compressed version, and forwards it to the model — so you pay for fewer input tokens without changing your application code.

Get Started with Headroom

Headroom is bring-your-own-proxy. Portkey does not host it. Deploy a Headroom proxy in your own infrastructure and point the integration at it — request payloads never leave your network.

Deploy a Headroom Proxy

Verify the deployment with curl http://your-headroom-host:8787/health.

Using Headroom with Portkey

1. Add Headroom Credentials to Portkey

  • Click on the Admin Settings button on Sidebar
  • Navigate to Plugins tab under Organisation Settings
  • Click on the edit button for the Headroom integration
  • Add your Headroom Proxy URL (for example https://headroom.internal.example.com:8787)
  • Add your Headroom Proxy Token — leave blank if the proxy runs without HEADROOM_PROXY_TOKEN

2. Add Headroom’s Guardrail Check

  • Navigate to the Guardrails page and click the Create button
  • Search for “Headroom Compress Context” and click Add
  • Configure the compression behaviour (all parameters are optional):
  • Set any actions you want on your check, and create the Guardrail!
Guardrail Actions allow you to orchestrate your guardrails logic. You can learn more about them here
Start with mode: audit to measure savings on real traffic without changing what reaches the model, then switch to optimize.

3. Add Guardrail ID to a Config and Make Your Request

  • When you save a Guardrail, you’ll get an associated Guardrail ID — add this ID to the input_guardrails param in your Portkey Config
  • Create these Configs in Portkey UI, save them, and get an associated Config ID to attach to your requests. More here.
For more, refer to the Config documentation.

Compression Results

Savings appear in the hook_results block of the response and in your Portkey logs:
compression_ratio is tokens_after / tokens_before, so lower is better — 0.35 means a 65% reduction. A ratio of 1.0 means nothing was compressed.

Compression Needs Large Inputs

Headroom skips content where compression would cost more than it saves, so small requests return zero savings by design. Content below roughly 300 tokens, JSON arrays under 5 items, and tool outputs under 500 tokens pass through unchanged, as does source code and the last protect_recent messages. Headroom pays off on long agent sessions, multi-tool workflows, API and database responses, build output, and structured logs — typically 40–95% reduction. Short conversational turns see close to nothing. Test with a realistic payload, not a one-line prompt.

Supported Request Types

Headroom compresses requests with a messages array:
  • Chat Completions (/v1/chat/completions)
  • Messages (Anthropic-style)
Requests without a messages array pass through untouched. Compression also fails open — if the proxy is unreachable, slow, or errors, the original request is sent to the provider and the failure is recorded in hook_results.

Get Support

If you face any issues with the Headroom integration, join the Portkey community forum for assistance.

Portkey is now PRISMA AIRS AI Gateway. See it in action.

Contact Us
Last modified on September 2, 2026