headroomlabs-ai/headroom · error · Error
withHeadroom() requires the "ai" package. Install it with: n
Error message
withHeadroom() requires the "ai" package. Install it with: npm install ai
What it means
Error "withHeadroom() requires the "ai" package. Install it with: npm install ai" thrown in headroomlabs-ai/headroom.
Source
Thrown at sdk/typescript/src/adapters/vercel-ai.ts:122
* const model = withHeadroom(openai('gpt-4o'));
* const { text } = await generateText({ model, messages });
* ```
*/
export function withHeadroom<T extends LanguageModel>(
model: T,
options: CompressOptions = {},
): T {
let wrapLanguageModel: (opts: {
model: T;
middleware: any;
}) => T;
try {
const require = createRequire(import.meta.url);
const ai = require("ai");
wrapLanguageModel = ai.wrapLanguageModel;
} catch {
throw new Error(
'withHeadroom() requires the "ai" package. Install it with: npm install ai',
);
}
return wrapLanguageModel({
model,
middleware: headroomMiddleware(options),
});
}
View on GitHub (pinned to 322425c43b)
Solutions
- Install the Vercel AI SDK: npm install ai
- Ensure the 'ai' package version is compatible with the withHeadroom adapter
When it happens
Trigger: Raised when withHeadroom() is called in a project where the 'ai' (Vercel AI SDK) package is not installed.
Common situations: See trigger scenarios.
AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15).
Data as JSON: /api/errors/afc7840b3ec28e49.
Report an issue: GitHub.