Observed since 20 Oct, 21:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Multi-provider rate limiter for LLM API pipelines
Multi-provider rate limiter for LLM API pipelines. Drop-in module that keeps you out of 429 Too Many Requests trouble across all the providers you use.
Retry-After when presentRateLimiter for both worldsplans.yaml with glob wildcards, easy to editpyyamlThe PyPI package is published as agamenox-ratelimiter (the plain ratelimiter name is taken on PyPI since 2013). The Python import stays as ratelimiter — different names, same module.
pip install agamenox-ratelimiter
# or, from source:
git clone https://github.com/Agamenox/ratelimiter.git
cd ratelimiter
pip install -e .
from ratelimiter import RateLimiter, call_with_retry
limiter = RateLimiter.from_yaml("plans.yaml")
# Wrap any function — auto 429 retry
def call_m3(prompt: str) -> str:
return call_with_retry(
limiter, "tokenrouter", "MiniMax-M3",
api_call_fn, prompt,
max_retries=5, base_backoff=1.0, max_backoff=60.0,
)
# Or acquire manually
limiter.acquire("tokenrouter", "MiniMax-M3")
response = api_call(...)
# Monitor usage
print(limiter.status("tokenrouter", "MiniMax-M3"))
# {'rpm_used': 5, 'rpm_limit': 300, 'tpm_used': 0, ...}
Async:
ok = await limiter.acquire_async("openrouter", "minimax/MiniMax-M2.5-highspeed")
I was running a batch pipeline through tokenrouter's free MiniMax-M3 model
and getting mysterious 429s. After a sustained-rate test I learned the limit
was 300 requests/minute, no rate limit headers, sliding 60s window — and
that the error only told me anything after I hit the wall.
So I built a small limiter, measured more providers, and packaged it up. Now my pipelines throttle themselves before the wall, and when they do hit it they back off cleanly with exponential jitter.
The key insight: different providers have different limits, different header conventions, and different retry semantics. Hardcoding any of it is a maintenance trap. Hence the YAML registry — you measure once, write it down, and the limiter does the right thing for every provider.
tokenrouter:
MiniMax-M3:
rpm: 300
tier: free
notes: "Empirically 300 RPM, no headers, sliding window."
openrouter:
"*:free":
rpm: 20
rpd: 200
tier: free
Fields: rpm (required), tpm, rpd, burst, tier (free|paid|enterprise|local), notes. Wildcards (*, ?) supported in the model field.
| Provider / Model | RPM | TPM | RPD | Source |
|---|---|---|---|---|
tokenrouter/MiniMax-M3 (free) | 300 | — | — | Empirical burst test |
openrouter/*:free | 20 | — | 200 | OpenRouter docs |
nvidia/* (NIM) | 40 | 800K | — | Conservative default |
zai/glm-5-turbo | 10 | 500K | — | User report |
minimax/M2.5-highspeed | 60 | 1M | — | Conservative |
opencode-go/* | 60 | 500K | — | Conservative |
lmstudio/* | ∞ | — | — | Local |
Naming note: PyPI package is agamenox-ratelimiter; Python import is ratelimiter (the module directory name). Use pip install agamenox-ratelimiter to install; from ratelimiter import ... to use.
If you've measured a different limit, open a rate-limit data issue so the registry stays honest.
lim = RateLimiter.from_yaml("plans.yaml") # or from_dict({...})
# Sync
ok = lim.acquire(provider, model, estimated_tokens=0, timeout=300)
lim.release(provider, model, estimated_tokens=0) # refund a slot
status = lim.status(provider, model) # snapshot dict
# Async
ok = await lim.acquire_async(provider, model, estimated_tokens=0)
# Auto-429 wrapper
result = call_with_retry(lim, provider, model, fn, *args,
max_retries=5, base_backoff=1.0, max_backoff=60.0,
estimated_tokens_fn=None)
Detects 429s from urllib, requests, httpx, and any object with
.status_code == 429. Reads Retry-After and X-RateLimit-* headers when
present.
python tests/test_limiter.py # 20 unit tests, < 0.5s, no network
python examples/integration_test.py # 5 real API calls to tokenrouter
The unit tests use a FakeClock so the time-dependent ones run in
milliseconds. The integration test requires pyyaml and a tokenrouter API key
(loaded from F:\dev\ratelimiter\examples\integration_test.py config).
GitHub Actions runs on every push and PR:
.py fileplans.yaml is loadableasync with limiter.guard(...) as ok:MIT — see LICENSE.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 16 Jun 2026 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:18 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:ad33674c84b3aaeecac53968531ec0bdb8330cc123daa84275b05dcbab55c440