rate-limit-budgetlisted
Install: claude install-skill baronguyen001/ai-automation-skills
# Rate Limit Budget
Use this skill when a run hammers an API and you want to pace it - smooth bursts to a steady rate so you stop earning 429s, and stop the whole run once a per-run call/credit budget is spent so a free-tier monthly quota survives. It is a token-bucket pacer: `acquire()` blocks just long enough to stay under the configured rate, and a separate budget counter raises once the run hits its cap. This is the teaching version; for the production library wired to a specific provider, see the cross-linked `helius-rate-limiter` repo.
## When to invoke
- User says: "rate-limit my API calls", "throttle these requests", "stay under the free-tier quota", "cap how many calls this run makes".
- Code in the conversation loops over many items and fires one API call each, with nothing pacing it.
## When NOT to invoke
- The server already paces you cleanly and a retry-on-429 (see `http-retry-session`) is enough.
- You need a distributed limiter shared across many machines - reach for Redis token buckets instead of an in-process one.
## Concrete example
User input:
```text
I call an API once per token and there are 400 of them. Keep it under 5 req/sec and never make more than 300 calls in one run.
```
Output:
```python
# Copy assets/budget.py into your project, then:
from budget import RateBudget, BudgetExceeded
pacer = RateBudget(rate_per_sec=5, burst=5, max_calls=300)
for token in tokens:
try:
pacer.acquire() # blocks just enough to hold 5