docs: add Headroom community provider for context compression#13866
Open
chopratejas wants to merge 2 commits intovercel:mainfrom
Open
docs: add Headroom community provider for context compression#13866chopratejas wants to merge 2 commits intovercel:mainfrom
chopratejas wants to merge 2 commits intovercel:mainfrom
Conversation
Add Headroom — context compression middleware for the AI SDK. Compresses tool outputs, search results, and large context before it reaches the model. 70-90% token savings on structured data, with accuracy preserved. - Community provider page with setup, usage, and configuration - Cookbook recipe: context compression middleware for Next.js agents - Added to community middleware section in middleware docs - Added to community providers list in foundations docs npm package: headroom-ai (published, zero dependencies) GitHub: https://github.com/chopratejas/headroom
content/cookbook/01-next/123-context-compression-middleware.mdx
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Headroom is an open-source context compression library for LLM applications. It compresses tool outputs, search results, database queries, and other large context before it reaches the model — typically saving 70-90% of input tokens while preserving accuracy.
The TypeScript SDK (
headroom-ai) is published on npm with zero dependencies. It provides acompress()function and aheadroomMiddleware()forwrapLanguageModel.No existing community provider or middleware addresses context compression. This fills a gap alongside caching (Upstash), observability (Helicone/PostHog), memory (Mem0/Hindsight), and routing (Portkey/OpenRouter).
Summary
4 files added/modified:
content/providers/03-community-providers/51-headroom.mdx— Community provider page with setup, usage (compress(),headroomMiddleware(), streaming, multi-provider), compression details, and configurationcontent/cookbook/01-next/123-context-compression-middleware.mdx— Cookbook recipe for building a context compression middleware in Next.js agentic appscontent/docs/02-foundations/02-providers-and-models.mdx— Added Headroom to community providers listcontent/docs/03-ai-sdk-core/40-middleware.mdx— Added Headroom to Community Middleware sectionChecklist
pnpm changesetin the project root)Future Work
extractReasoningMiddleware)prepareStepintegration for progressive compression in multi-step agentsRelated Issues
N/A — new community provider addition.