> ## Content Index
> Fetch the complete content index at: https://www.stirup.si/llms.txt
> Use this file to discover other available public pages before exploring further.

# LLMBrake Manages Per-Customer AI API Budgets with Automatic Model Downgrades
- URL: https://www.stirup.si/llmbrake-manages-per-customer-ai-api-budgets-with-automatic-model-down-08a4b54a/
- Published: 2026-11-06T00:39:09.000Z
- Updated: 2026-11-06T00:39:09.000Z
- Description: LLMBrake is a TypeScript library that manages per-customer cost caps for AI applications using OpenAI-compatible APIs by automatically switching to cheaper models as budgets are approached.
- Author: Satish Das
- Tags: Community, News, Stirup Research

## Overview of LLMBrake's Functionality

LLMBrake is a TypeScript library designed to manage per-customer cost caps for AI applications that use OpenAI-compatible APIs. It allows developers to set a monthly dollar budget for each customer and automatically switches them to a cheaper model as they approach their limit. When the budget is reached, LLMBrake blocks further API calls to prevent overspending. The library wraps the `chat.completions.create` method, ensuring seamless integration with existing applications. Notably, LLMBrake does not store or process any prompts or completions, maintaining user privacy by only tracking customer ID, plan, feature tag, model, token counts, cost, and timestamps. This approach ensures that developers can control costs effectively without compromising data security or user experience.

## Implementation Details and Usage

LLMBrake implements per-customer dollar caps for OpenAI and Anthropic API calls by wrapping each request in a budget-checking mechanism. When a call is made, the system first checks the customer's allocated budget for the current calendar month (UTC). If the budget is exceeded, the system triggers a downgrade, redirecting requests to a lower-tier model, such as sending `gpt-5.5` requests to `gpt-5.4-mini`. This occurs automatically when usage reaches 80% of the budget, as defined by the `downgradeAt` parameter. The implementation uses a `guard` object to wrap API calls, ensuring that each request is evaluated against the customer's plan and budget. If a budget limit is exceeded, an error is thrown, allowing the system to display an upgrade prompt to the user. The system also provides status updates, returning details such as the period, spent USD, and remaining budget for a given customer. This approach ensures that API usage remains within predefined financial limits while maintaining service continuity.

## HostedStore and Budget Management

LLMBrake's HostedStore feature enables shared budget management across multiple servers and serverless instances by maintaining counters in the LLMBrake Cloud. This ensures that all instances using the same project's API key share a single counter per customer, and any budget adjustments made in the dashboard take effect on the next API call without requiring Redis infrastructure. The system also addresses the issue of concurrent API call overshoot by reserving an estimated cost before each call, ensuring that the total estimated spend plus in-flight reservations remains within the budget in a single atomic step on the server. Once the call is completed, the system settles the actual cost and releases the hold, with failed provider calls releasing the hold at $0.

## Model Pricing and Customization

The LLMBrake tool introduces per-customer dollar caps for API calls to OpenAI and Anthropic models, offering businesses greater control over their spending. Model pricing is a critical factor in this system, with DEFAULT\_PRICES providing a snapshot of standard-tier rates for common models in USD per 1 million tokens, as of 2026-10-09 [(OpenAI)](https://developers.openai.com/api/docs/pricing?ref=stirup.si) and [(Anthropic)](https://docs.anthropic.com/en/docs/about-claude/pricing?ref=stirup.si). These prices are subject to change frequently and should not be considered guarantees.

Users can customize pricing tables by overriding or extending DEFAULT\_PRICES through the `createGuard` function, allowing for tailored budgeting. For example, a budget of $5 USD can be set with custom model rates. However, only chat-completions-style token usage is currently metered, with no support for images, audio, embeddings, or tool fees at this time.

## Additional Features and Ports

LLMBrake offers additional features and ports to enhance its functionality. A Python port with identical behavior is available in the python/ directory, supporting sync and async OpenAI clients, streaming, and pluggable stores such as in-memory and Redis options, with no required dependencies and compatibility with Python 3.9+. Additionally, LLMBrake Cloud serves as an optional paid layer, providing shared counters (HostedStore), a dashboard that displays spend, budget, and status per customer, with the ability to edit budgets live. It also includes Slack/webhook alerts at 80% and 100% thresholds, and tracks AI cost metrics. The core library remains free and MIT licensed, as noted in the source.

## Sources and reporting notes

- [Hacker News Show](https://github.com/llmbrake/llmbrake?ref=stirup.si)

Based on published source material. No independent hands-on testing is claimed.