How to Set Budget Limits on AI Agents (Step by Step)
Two Types of Budget Limits
Before you set budget limits, it's worth understanding the two types and what each one does.
Provider total caps — Set on OpenAI, Anthropic, or Google. Stops all API calls when your total account spend reaches a threshold. Protects against catastrophic overspend but applies to every agent and workflow equally.
Per-agent budget caps — Set in your monitoring tool. Stops a specific agent when it hits its budget. Other agents keep running. This is what AgentShield adds.
Most teams need both.
Step 1: Set a Provider-Level Safety Net
First, set a hard cap on your provider account. This is your last line of defense.
OpenAI:
1. Go to platform.openai.com → Settings → Limits
2. Set a "Hard limit" — all API calls stop when this is hit
3. Set a "Soft limit" — you get an email warning before the hard limit
Anthropic:
Anthropic uses a prepaid credit model. Buy credits, and usage draws from that balance. Set your initial credit purchase conservatively until you understand your usage patterns.
Google AI:
Set billing alerts in Google Cloud Console at 50%, 80%, and 100% of your expected budget.
Step 2: Identify Your Agents and Their Expected Costs
Before setting per-agent caps, you need baselines. If you don't have them yet, run your agents for a week with tracking enabled and measure.
Typical patterns:
Set your initial caps at 3-5x your expected daily cost. This gives room for legitimate spikes while catching runaway loops.
Step 3: Set Per-Agent Caps in AgentShield
Using the Python SDK:
import agentshield as shield
# Set a daily budget cap with automatic freeze
shield.set_budget(
agent_id="research-agent",
max_usd=50.0,
period="daily",
action="freeze" # or "alert" for email/Slack only
)
# Set a monthly cap on a cheaper agent
shield.set_budget(
agent_id="support-agent",
max_usd=200.0,
period="monthly",
action="freeze"
)Using the REST API (for n8n, Make, Zapier, or any language):
curl -X POST https://api.agentshield.one/v1/budgets \
-H "Authorization: Bearer ags_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "research-agent",
"max_usd": 50.0,
"period": "daily",
"action": "freeze"
}'Step 4: Configure Alerts
Set up alerts before the cap is hit:
shield.set_alert(
agent_id="research-agent",
threshold_pct=80, # Alert at 80% of budget
channels=["email", "slack"]
)This gives you time to investigate before the agent freezes.
Step 5: Test Your Caps
Before going to production, verify your caps work:
1. Set a very low cap (e.g., $0.01) on a test agent
2. Make a few API calls through it
3. Verify the agent freezes and you receive the alert
4. Reset the cap to your production value
What Happens When a Cap Is Hit
When an agent hits its budget cap with action set to "freeze":
This is the key difference from provider total caps: one agent's problem doesn't affect the rest.
Recommended Cap Strategy
| Agent type | Daily cap | Monthly cap | Action |
|-----------|-----------|-------------|--------|
| Support/customer | $10 | $200 | Freeze |
| Research/long-context | $50 | $500 | Alert at 80%, freeze at 100% |
| Classifier/cheap | $5 | $50 | Freeze |
| Experimental/new | $2 | $20 | Freeze |
Start conservative. You can always raise caps. It's harder to explain a surprise $800 charge.
Ready to monitor your AI agents?
Set up AgentShield in 5 minutes. Free plan available.
Start for Free →