A lightweight, zero-latency local reverse proxy and circuit breaker designed specifically for AI coding agents and LLM client tools.
When running autonomous coding agents (OpenCode, Cursor, Aider, Claude Code), hitting a 429 Too Many Requests or quota exhaustion stops the entire loop dead in its tracks.
quota-guard sits locally between your tools and upstream providers. When your cloud quotas run dry or rate-limits spike:
- Trips the circuit breaker immediately without dropping connections.
- Transparently reroutes streaming requests to local engines (Ollama, LocalAI, vLLM) or a secondary provider.
- Probes upstream in
HALF_OPENstate after a configurable cooldown and restores primary traffic automatically.
# Point your agent to localhost:8080 instead of https://api.openai.com
npx quota-guard --upstream https://api.openai.com --fallback http://127.0.0.1:11434Check live traffic and circuit health anytime:
curl http://127.0.0.1:8080/_quota_guard/stats| Flag | Short | Default | Description |
|---|---|---|---|
--port |
-p |
8080 |
Local port to bind proxy. |
--upstream |
-u |
https://api.openai.com |
Primary upstream API. |
--fallback |
-f |
http://127.0.0.1:11434 |
Fallback model server (e.g. Ollama). |
--threshold |
-t |
2 |
Number of consecutive 429/5xx before circuit opens. |
--cooldown |
-c |
30000 |
Cooldown period (ms) before testing upstream again. |
MIT © luckdevx