kani-ratelimits
This is a simple, small package to to enforce request-per-minute (RPM), token-per-minute (TPM), and/or max-concurrency ratelimits before making requests to an underlying engine.
Installation
pip install kani-ratelimits
Usage
from kani.ext.ratelimits import RatelimitedEngine
# limit requests to 10 req/min and 30k tokens/min
inner_engine = ... # your engine here, e.g. `OpenAIEngine(..., model="gpt-4")`
engine = RatelimitedEngine(inner_engine, rpm_limit=10, tpm_limit=30_000)
The RatelimitedEngine takes the following parameters:
engine: The engine to wrap.max_concurrency(int): The maximum number of concurrent requests to serve at once (default unlimited).rpm_limit(float): The maximum number of requests to serve per rpm_period (default unlimited).rpm_period(float): The duration, in seconds, of the time period in which to limit the rate. Note that up to rpm_limit requests are allowed within this time period in a burst (default 60s).tpm_limit(float): The maximum number of tokens to send in requests per tpm_period (default unlimited).tpm_period(float): The duration, in seconds, of the time period in which to limit the rate. Note that up to tpm_limit tokens are allowed within this time period in a burst (default 60s).
The ratelimiter will ensure that all conditions are met before forwarding the request to the wrapped engine.
Metadata
Release files for kani-ratelimits 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kani_ratelimits-1.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kani_ratelimits-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / kani_ratelimits-1.1.0.tar.gz
| Download URL | kani_ratelimits-1.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e90e14e54eb55698ca941391cfe7eea0a03089083f7e53fb58e2bb832da4615c
|
|
BLAKE2b-256 checksum How to use checksums |
2a729b0e4294508dda11a4ba9b3c72b270afb240cdd5a54e7b88b373c68bcf42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2025.
Transparency logRelease files / kani_ratelimits-1.1.0-py3-none-any.whl
| Download URL | kani_ratelimits-1.1.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f42124a84ebc1e0d9ba451bd3432ee1554bc21f11d9f522b200a96ceef857187
|
|
BLAKE2b-256 checksum How to use checksums |
52ab33f50ff5da8c4be55443f956e4475577d95dce2cb1d5487f0a14d5671c64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2025.
Transparency log