How to Set Up OpenClaw Spending Limits and Budget Alerts | OpenClaw DC
To prevent surprise API bills, set spending caps on your API provider dashboard (OpenAI, Anthropic both support hard limits), configure token limits in OpenClaw config, and set up billing alerts on your cloud provider.
To prevent surprise API bills, set spending caps on your API provider dashboard (OpenAI, Anthropic both support hard limits), configure token limits in OpenClaw config, and set up billing alerts on your cloud provider. Here is how to do all three. Most users can complete the full setup in under ten minutes, and the result is a layered safety net that catches runaway costs at every level of the stack.
Step 1: Set Hard Spending Caps on Your API Provider
Your API provider is the first line of defense. Both OpenAI and Anthropic let you set hard spending limits that completely stop API calls once you hit the threshold. No exceptions, no overages.
OpenAI
- Log in at platform.openai.com.
- Click Settings in the left sidebar.
- Select Billing and then Usage limits.
- Set a Hard limit (API calls stop entirely) and a Soft limit (sends you an email warning).
- Click Save.
For personal OpenClaw use, a hard limit of $20 and a soft limit of $15 gives you plenty of room while preventing bill shock.
# Example OpenAI limits for personal use Hard limit: $20/month Soft limit: $15/month (triggers email alert)
Anthropic
- Log in at console.anthropic.com.
- Navigate to Settings then Spending Limits.
- Set a Monthly budget (hard cap that blocks further calls).
- Optionally configure a notification threshold below the cap.
- Save your changes.
Anthropic enforces the limit at the account level. Once you hit it, every API key under that account stops working until the next billing cycle or until you raise the limit manually.
# Example Anthropic limits for personal use Monthly budget: $25 Notification at: $18 (email alert)
These provider-level caps are the most important safeguard. Even if every other layer fails, your bill cannot exceed the hard limit you set here.
Step 2: Configure Token Limits in OpenClaw
Provider caps protect your wallet, but OpenClaw config limits protect individual tasks from consuming your entire budget in a single run. A misconfigured prompt or an infinite tool-calling loop can burn through thousands of tokens in seconds. Setting per-task and per-session limits stops that.
Edit your OpenClaw config file at ~/.openclaw/config.yaml:
# ~/.openclaw/config.yaml limits: max_tokens_per_task: 8000 # hard cap per individual task max_tokens_per_session: 50000 # cap across all tasks in one session max_turns_per_task: 10 # prevent infinite tool-call loops warn_at_tokens: 5000 # print a warning in the CLI
These values work well for typical personal use. If you run complex multi-step research tasks, you may want to raise max_tokens_per_task to 15,000 or 20,000. For simple automation (renaming files, formatting text), you can lower it to 3,000.
You can also set per-model limits if you use ClawRouter to route tasks to different providers:
# Per-model limits in ~/.openclaw/router.yaml
routes:
- match: "summarize|format|rename"
model: ollama/qwen3.5:27b
max_tokens: 3000
- match: "analyze|research|debug"
model: anthropic/claude-3.5-sonnet
max_tokens: 15000
- default:
model: openai/gpt-4o-mini
max_tokens: 5000
This way, cheap local tasks get a tight leash while expensive cloud tasks get the room they need, but nothing more.
Step 3: Set Up Cloud Provider Billing Alerts
If you run OpenClaw on a VPS or cloud server, your hosting bill is a separate cost to watch. Here is how to set alerts on three popular providers.
DigitalOcean: Go to Settings then Billing then Alert Preferences. Set a monthly threshold (for example, $10) and DigitalOcean emails you when projected usage crosses it.
AWS: Open the Billing and Cost Management console. Navigate to Budgets then Create budget. Choose a monthly fixed budget, enter your amount, and add your email as a notification recipient. AWS can alert at 50%, 80%, and 100% of budget.
Hetzner: Hetzner does not offer built-in billing alerts. Instead, set a monthly calendar reminder to check your Hetzner Cloud console, or use the Hetzner API to query your current charges in a cron job.
Step 4: Build a Simple Usage Monitoring Script
For an extra safety net, run a lightweight script on a cron schedule that checks your API usage and sends an alert when it crosses a threshold.
#!/bin/bash
# save as ~/openclaw-budget-check.sh
THRESHOLD=15 # alert when usage exceeds $15
USAGE=$(openclaw usage --format json 2>/dev/null | python3 -c "
import sys, json
data = json.load(sys.stdin)
print(f\"{data.get('total_cost_usd', 0):.2f}\")
")
if (( $(echo "$USAGE > $THRESHOLD" | bc -l) )); then
echo "OpenClaw usage alert: \$$USAGE spent this billing cycle (threshold: \$$THRESHOLD)" \
| mail -s "OpenClaw Budget Warning" you@example.com
fi
Schedule it to run every six hours:
# Add to crontab with: crontab -e 0 */6 * * * /bin/bash ~/openclaw-budget-check.sh
This script queries the OpenClaw CLI for your current spend, compares it to your threshold, and sends a plain-text email if you are over. Swap mail for any notification tool you prefer: a Slack webhook, a Telegram bot, or a simple curl to a Discord channel.
What Happens When You Hit the Limit
When your API provider hard limit kicks in, all API requests return a 429 Too Many Requests error. OpenClaw handles this gracefully: the current task fails with a clear message (“API rate limit or spending cap reached”), and no further charges accrue. Queued tasks will not retry against a spending cap. They simply wait.
You have three options at that point:
- Wait for the billing cycle to reset (usually the 1st of the month).
- Raise the hard limit on your provider dashboard and continue immediately.
- Switch to a local model via Ollama for $0 cost until the cycle resets.
Option 3 is the best approach for most users. Keep a local model configured as a fallback so that basic tasks keep running even when your cloud budget is spent. Your monthly cost stays predictable, and you never lose productivity.
Recommended Budget Tiers
- Casual personal use (5-10 tasks/day): $10-15/month API hard limit
- Power personal use (20-40 tasks/day): $25-40/month API hard limit
- Small business (multiple agents): $100-250/month API hard limit
- Zero cost: Use Ollama with a local model and skip API providers entirely
For a full breakdown of what each provider costs at different usage levels, see our API costs comparison and complete cost guide.
Start Protecting Your Budget Today
Setting up spending limits takes less time than recovering from a surprise bill. Start with the API provider hard cap (Step 1), then add OpenClaw config limits (Step 2), and layer on cloud alerts and the monitoring script when you are ready. Every layer you add makes bill shock less likely.
If you need help configuring limits for your setup, reach out at support@openclawdc.com and we will walk you through it.
Get guides like this in your inbox every Wednesday.
No spam. Unsubscribe anytime.
You'll probably need this again.
Press Cmd+D (Mac) or Ctrl+D (Windows) to bookmark this page.
Need help with your OpenClaw setup?
We do remote setup, troubleshooting, and training worldwide.
Book a Call