How to set budget limits for AI agents in production
An AI agent without a budget limit is an open tab on your API bill. The simplest fix is to set limits at three levels (per run, per agent and per team) and to stop the agent, not only alert, when a limit is hit. This guide shows how to choose the numbers and where to enforce them.
Why agents overspend
Agents loop, retry and call tools. One bad prompt or a failing tool can turn a 5-cent task into a very large bill, and you only see it at the end of the month in the provider dashboard. Provider-level caps are blunt: they stop everything, not just the broken agent.
The three levels of limits
- Per run: the maximum tokens or cost for one execution. Catches infinite loops.
- Per agent: a daily or monthly cap for one agent. Catches one agent that behaves badly.
- Per team or project: a shared ceiling for all agents. Catches the sum of many small leaks.
How to pick the numbers
Run the agent 10-20 times on real tasks and record the cost of each run. Set the per-run limit at about 3 times the typical cost, so normal variation passes but a loop does not. Set the daily cap from the expected number of runs times the typical cost, plus a margin. Revisit after a week.
Alert, pause or stop?
Alerts alone are ignored at 3 a.m. Use a soft limit (for example 80 percent) to notify, and a hard limit to pause the agent and ask a human to continue. Pairing a budget with a human approval step means the person decides whether the extra spend is worth it.
Bring your own keys, keep your own control
If you use your own provider API keys, the provider bills you directly, so limits must live in the layer that runs your agents. FleetQ is mission control for AI agents: budgets, human approvals and an audit log in one place, free on your own server (AGPL) or in Cloud with your own keys.
Checklist
- Measure the real cost of 10 runs.
- Set a per-run, per-agent and per-team limit.
- Add a soft alert and a hard stop.
- Require approval to raise a limit.
- Log every stop so you can review it later.
FAQ
Is a provider spend cap enough?
It protects the account, but it stops all agents at once and gives no per-agent view.
What happens when an agent hits its limit?
It should pause and report, so a person can approve more budget or fix the cause.
Can I use my own API keys?
Yes. FleetQ supports bringing your own keys in Cloud Free and on self-hosted installs.
Where do I start?
Try the cost estimator at /tools/ai-agent-cost-estimator to size a limit.
Related guides
- Manage AI agents through MCP MCP lets an AI assistant call tools in another system. FleetQ ships an MCP server, so the assistant you already use can work with your agent fleet.
- AI agent audit log When an agent sends a wrong email or burns through your LLM budget, the first question is always the same: what exactly happened? Without an audit log you guess. With one you read it.
- Self-host an AI agent platform Some teams cannot send agent data to a third party, or want to own the stack. FleetQ is open source (AGPL-3.0) and runs on your own server.
- MCP firewall for AI agents Decide which MCP tools an agent may call on its own, which need a human yes in Slack or Telegram, and which are blocked, with a budget cap on top.
- Keep API keys away from AI agents On hosted Claude Code runs the agent only gets a short-lived token. The secret proxy adds the real credential only for the hosts the run needs.
- Build AI agents in Python Drive FleetQ agents from Python over the REST API: create a token, chat with an agent, start governed runs and approve steps with plain requests calls.
- Human in the loop for AI agents Human-in-the-loop means a person approves an agent's action before it happens. You do not need it for every step, only for actions that are costly, irreversible or external.
- AI agent cost estimator
- Use cases
- All guides