Anticipatory rate-limit orchestration engine for multi-provider systems
Project description
grate-limiter (Python)
Anticipatory rate-limit orchestration engine for multi-provider systems.
Predict limits before providers enforce them.
This is the Python port of grate-limiter. For detailed documentation, see the main repository.
Installation
pip install grate-limiter
Quick Start
from grate_limiter import *
# Create the engine
engine = GrateLimiter(EngineConfig())
# Register providers with their quotas
engine.upsert_provider(ProviderConfig(
name="openai",
quotas=[QuotaConfig(dimension=Dimension.REQUESTS, limit=5000, window=Window.MINUTE)],
priority=10,
cooldown_seconds=30,
))
engine.upsert_provider(ProviderConfig(
name="anthropic",
quotas=[QuotaConfig(dimension=Dimension.REQUESTS, limit=3000, window=Window.MINUTE)],
priority=8,
cooldown_seconds=30,
))
# Register a capability
engine.upsert_capability(CapabilityConfig(
name="chat-completion",
providers=[
CapabilityProvider(provider="openai", priority=10),
CapabilityProvider(provider="anthropic", priority=8),
],
))
# Select the best provider
decision = engine.select("chat-completion")
print(f"Use: {decision.provider} (score: {decision.score:.2f})")
# Report what happened
engine.observe(Observation(
provider="openai",
capability="chat-completion",
usage=Usage(requests=1, tokens=1200),
outcome=Outcome(status=StatusClass.SUCCESS, latency_ms=830),
))
Deterministic Testing
from grate_limiter import GrateLimiter, EngineConfig, MockClock
clock = MockClock()
config = EngineConfig().with_clock(clock)
engine = GrateLimiter(config)
# Time only advances when you say so
clock.advance_ms(5000)
clock.advance_secs(60)
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grate_limiter-0.1.0.tar.gz.
File metadata
- Download URL: grate_limiter-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f944e0036d6a53055ffa1db55ff069748ca95035e4a69af3bc01be4c09b63b
|
|
| MD5 |
d0c93c8ca6b3e696dcfb59c4453a670a
|
|
| BLAKE2b-256 |
114c5e57a73be7a7a0c8187af64f0ab26940911a102eee4df1d14227e15251e5
|
Provenance
The following attestation bundles were made for grate_limiter-0.1.0.tar.gz:
Publisher:
release.yml on dev-kasibhatla/grate-limiter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grate_limiter-0.1.0.tar.gz -
Subject digest:
92f944e0036d6a53055ffa1db55ff069748ca95035e4a69af3bc01be4c09b63b - Sigstore transparency entry: 1523102902
- Sigstore integration time:
-
Permalink:
dev-kasibhatla/grate-limiter@21f48216153cbf271a3b3daab3886e6e8f200e7b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dev-kasibhatla
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@21f48216153cbf271a3b3daab3886e6e8f200e7b -
Trigger Event:
push
-
Statement type:
File details
Details for the file grate_limiter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: grate_limiter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
964fd9aa6db8ead00d4934be4927b1bf73e014721dee09a2b1c88143db97009d
|
|
| MD5 |
7382ff2a0cbcf6995350b45aaf0c0776
|
|
| BLAKE2b-256 |
7f8e72c60d490fb9edbaf38a05786603fe973c7a6fdcd59b435b1f8c48d59ad8
|
Provenance
The following attestation bundles were made for grate_limiter-0.1.0-py3-none-any.whl:
Publisher:
release.yml on dev-kasibhatla/grate-limiter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
grate_limiter-0.1.0-py3-none-any.whl -
Subject digest:
964fd9aa6db8ead00d4934be4927b1bf73e014721dee09a2b1c88143db97009d - Sigstore transparency entry: 1523102905
- Sigstore integration time:
-
Permalink:
dev-kasibhatla/grate-limiter@21f48216153cbf271a3b3daab3886e6e8f200e7b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/dev-kasibhatla
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@21f48216153cbf271a3b3daab3886e6e8f200e7b -
Trigger Event:
push
-
Statement type: