LLM providers enforce rate limits to prevent abuse and ensure fair resource allocation. When OpenClaw exceeds these limits, you'll see 429 Too Many Requests errors. This can happen from burst traffic, aggressive polling, running multiple OpenClaw instances with the same API key, or simply hitting tier limits. This guide shows you how to implement proper retry logic, request queuing, and key distribution.
Why This Is Hard to Do Yourself
These are the common pitfalls that trip people up.
Provider tier rate limits
Free tier: 10 req/min, Paid tier: 100 req/min, hitting caps during peak usage
Burst traffic spikes
Sudden influx of requests overwhelming available quota
No retry logic or exponential backoff
Failed requests not retried, or retry storms making rate limiting worse
Multiple instances sharing one key
Load balancer or horizontal scaling using same API key, multiplying request rates
Step-by-Step Guide
Identify which provider is rate limiting
Check logs and error responses to determine if it's Anthropic, OpenAI, or another provider.
# Search logs for 429 errors:
grep -i "429\|rate.limit" ~/.openclaw/logs/openclaw.log | tail -20
# Example output:
# 2025-03-01T10:23:45 ERROR: Anthropic API returned 429
# {"error": {"type": "rate_limit_error", "message": "Rate limit exceeded"}}
# Check which provider:
grep -i "rate.limit" ~/.openclaw/logs/openclaw.log | grep -oE "(anthropic|openai|google)" | sort | uniq -c
# Check rate limit headers in response:
curl -I https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
| grep -i "rate-limit"Check current usage against limits
Review your provider dashboard to see quota utilization and tier limits.
# Anthropic: Check usage dashboard
# https://console.anthropic.com/settings/usage
# Look for:
# - Requests per minute (RPM) limit
# - Tokens per minute (TPM) limit
# - Current usage percentage
# OpenAI: Check rate limits page
# https://platform.openai.com/account/rate-limits
# Note tier limits:
# - Free: 3 RPM, 40K TPM
# - Tier 1: 500 RPM, 600K TPM
# - Tier 2: 5000 RPM, 5M TPM
# Calculate your request rate:
grep "API request" ~/.openclaw/logs/openclaw.log | \
awk -F: '{print $1":"$2}' | \
uniq -c | \
sort -rn | \
head -10
# Shows requests per minuteImplement retry with exponential backoff
Configure OpenClaw to automatically retry failed requests with increasing delays.
# Edit OpenClaw retry config:
nano ~/.openclaw/.env
# Add retry settings:
ENABLE_RETRY=true
MAX_RETRIES=5
RETRY_BASE_DELAY=1000 # Start with 1 second
RETRY_MAX_DELAY=60000 # Cap at 60 seconds
RETRY_EXPONENTIAL_BACKOFF=true
RETRY_JITTER=true # Add randomness to prevent thundering herd
# Only retry on specific errors:
RETRY_ON_ERRORS=429,503,500
# Example retry delays:
# Attempt 1: 1s + jitter
# Attempt 2: 2s + jitter
# Attempt 3: 4s + jitter
# Attempt 4: 8s + jitter
# Attempt 5: 16s + jitterConfigure request queuing and throttling
Limit concurrent requests to stay under provider rate limits.
# Set request queue limits:
nano ~/.openclaw/.env
# Add:
MAX_CONCURRENT_REQUESTS=5 # Max parallel LLM requests
REQUEST_QUEUE_SIZE=100 # Buffer incoming requests
QUEUE_TIMEOUT=60000 # Fail if queued > 60s
# Per-provider rate limits:
ANTHROPIC_MAX_RPM=50 # Requests per minute
ANTHROPIC_MAX_TPM=100000 # Tokens per minute
OPENAI_MAX_RPM=100
OPENAI_MAX_TPM=500000
# Enable request pacing:
ENABLE_REQUEST_PACING=true
MIN_REQUEST_INTERVAL=100 # Minimum 100ms between requestsDistribute load across multiple API keys
Use key rotation to spread requests across multiple provider accounts.
# Configure multiple API keys:
nano ~/.openclaw/.env
# Add multiple keys:
ANTHROPIC_API_KEYS=sk-ant-api03-key1,sk-ant-api03-key2,sk-ant-api03-key3
# Enable round-robin rotation:
ENABLE_KEY_ROTATION=true
KEY_ROTATION_STRATEGY=round_robin # Or: random, least_used
# Monitor per-key usage:
ENABLE_KEY_USAGE_TRACKING=true
# Automatically disable keys hitting limits:
AUTO_DISABLE_RATE_LIMITED_KEYS=true
KEY_COOLDOWN_PERIOD=300 # Wait 5 min before retrying
# Check key rotation status:
curl http://localhost:3000/api/keys/status | jq .Set up rate limit monitoring and alerts
Track rate limit hits and get notified before hitting hard limits.
# Enable rate limit metrics:
nano ~/.openclaw/.env
ENABLE_RATE_LIMIT_METRICS=true
# Log rate limit warnings:
grep "approaching.rate.limit\|rate.limited" ~/.openclaw/logs/openclaw.log
# Create monitoring script:
cat > monitor-rate-limits.sh << 'EOF'
#!/bin/bash
RATE_LIMIT_COUNT=$(grep -c "429" ~/.openclaw/logs/openclaw.log)
if [ "$RATE_LIMIT_COUNT" -gt 10 ]; then
echo "Rate limit errors: $RATE_LIMIT_COUNT" | \
mail -s "OpenClaw Rate Limit Alert" admin@example.com
fi
EOF
chmod +x monitor-rate-limits.sh
# Run every 5 minutes:
(crontab -l ; echo "*/5 * * * * /path/to/monitor-rate-limits.sh") | crontab -Constant Rate Limit Headaches?
Our optimization experts implement sophisticated request queuing, multi-key load balancing, and predictive rate limit monitoring. Get smooth, uninterrupted service even under heavy load.
Get matched with a specialist who can help.
Sign Up for Expert Help โ