Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

limitry

The Limitry Python SDK puts a limit around costly work in a with block: guard checks before the block runs, and reserve reserves what the work will probably cost, then charges what it actually cost. Every API operation is a typed method too, sync or async.

Limitry is the limits, credits and budgets layer for your software: give each of your users, teams, tenants, API keys or agents an allowance, and before any costly action one call tells your code whether it may happen.

Install

pip install limitry

Needs Python 3.10 or later. Set LIMITRY_API_KEY to a key from API keys in the app. Use a test key (lim_test_…) while you build.

Guard costly work

guard checks the limit, then runs the block only if it's allowed. Here it counts one AI call against a limit such as 100 a day:

from limitry import LimitReached, Limitry

limitry = Limitry()  # reads LIMITRY_API_KEY

try:
    with limitry.guard(subject={"kind": "user", "id": "usr_123"}, action="ai-call"):
        reply = call_model(prompt)
except LimitReached as error:
    print(f"Try again in {error.retry_after_seconds} seconds")

Charge what it actually cost

When you only know the cost afterwards, such as an AI reply priced by the token, reserve reserves what it will probably cost (5 cents here), runs the block and charges what it used. If the block raises, the reservation is released:

from limitry import Limitry

limitry = Limitry()

with limitry.reserve(
    subject={"kind": "user", "id": "usr_123"}, action="ai-call", cost=5
) as reservation:
    response = call_model(prompt)
    reservation.cost(price_cents(response.usage))  # your prices, in cents

A refusal raises LimitReached. If Limitry can't be reached, each limit's fail mode decides: open lets the work run, closed raises Unavailable.

Everything else

Every API operation is a typed method, named like its CLI command: limitry limits create is limitry.limits.create(). For asyncio, use AsyncLimitry.

from limitry import Limitry

limitry = Limitry()

# "100 units per user per day for ai-call"
limitry.limits.create(
    subject={"kind": "user"},
    action="ai-call",
    amount=100,
    window="day",
)

A failure raises ApiError with the error's code, message, status and request_id.

Contributing

This repository is generated from Limitry's source on each release, so pull requests are ported there and credited (see CONTRIBUTING.md).

License

Licensed under the Apache License 2.0.

Metadata

Release files for limitry 1.0.0rc6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for limitry 1.0.0rc6
File Size Uploaded Provenance Actions
limitry-1.0.0rc6.tar.gz 28.3 kB With provenance Details for limitry-1.0.0rc6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for limitry 1.0.0rc6
File Interpreter ABI Platform Actions
limitry-1.0.0rc6-py3-none-any.whl Python 3 none any Details for limitry-1.0.0rc6-py3-none-any.whl

Total release size: 61.3 kB

Release files / limitry-1.0.0rc6.tar.gz

Download URL limitry-1.0.0rc6.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3e241b804afd60800cb081bb27f8b0b6425f117012ea31d461e9b242f541984c
BLAKE2b-256 checksum
How to use checksums
23fc20f3cce0963e62adc741cc2490d9ec1d97a984fe90c25687c63f98942456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

Release files / limitry-1.0.0rc6-py3-none-any.whl

Download URL limitry-1.0.0rc6-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0fa3ba55f6e0a92e5f07a1cb3a1c2de1f6dbea7ba5266aeb8802053b9b94e0c
BLAKE2b-256 checksum
How to use checksums
833c7901178bce42540f08543ed920a73bd6b3279d3555e0548c42f244b43262
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 20, 2026.

Transparency log

Security for limitry 1.0.0rc6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for limitry-1.0.0rc6.tar.gz

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 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page