GuidesAI development
Capping your AI API bill: five safeguards
The five safeguards
- 1Provider limitA monthly cap in the console, per workspace.
- 2Answer cap
max_tokenson every call. - 3Per-user quotaA number of calls per hour and per day.
- 4AlertsAt 50% and 80% of the monthly budget.
- 5LogTokens and cost per feature, reviewed every week.
The classic causes of a runaway bill
| Cause | Fix |
|---|---|
| An agent stuck in a loop | A maximum number of steps |
| A public form hit by a bot | Quota, captcha, authentication |
| An endless conversation history | Summarise after a few turns |
| A whole document sent with every question | A RAG that sends only the useful passages |
| The biggest model everywhere | A lighter model for simple tasks |
Estimate first
The token calculator and the conversation cost calculator give the order of magnitude. For the overall budget: how much an AI project costs.
Frequently asked questions
- Can the provider cut things off itself?
- Most consoles let you set a monthly spend limit per account or workspace. Beyond it, calls are refused. It is the last safety net, not the only one.
- What does the user see when the limit is hit?
- A clear message you planned (“service temporarily unavailable”), never a technical error. Set up an alert for yourself too.
- How do I know what each feature costs?
- By logging, for every call, the feature, the user and the input and output tokens returned by the API.