Limitr for Python
Limitr 0.8.7 is out, and Limitr now runs in Python.
pip install limitr
It's the same engine as the TypeScript SDK, not a port of it. The engine is a Stof document, so the Python SDK loads the very same document (your policy, its functions, and every customer's state) and runs it in your process. A policy you wrote for a Node service works unchanged in a Python one, and both can serve the same customers through Limitr Cloud.
from limitr import Limitr
limitr = Limitr(policy, 'yaml')
limitr.ensure_customer('acme', 'pro')
limitr.allow('acme', 'export_pdf') # True
limitr.allow('acme', 'chat', 2_100_000) # True, soft limit
# event: meter-overage → bill acme: $2
What's in it
- Everything the engine does: plans, credits, limits, spend caps, grants and top-ups, reservations and estimates
for LLM calls, feature flags and rules, custom deals, capabilities as Claude tools, and margin on every call. The
Python SDK reference lists every method; if you know the TypeScript SDK, it's the same
API in snake_case, with plain calls in place of
await. - Limitr Cloud:
Limitr.cloud(token)follows the policy you publish, live, loads customers when a call first needs them, and sends usage back in batches over a background connection. Every decision still runs in-process. - Limitr Network: your Python agents can connect to providers, and your Python services can be providers, over the same protocol as TypeScript, so either side can be either language.
- Threads: one engine is safe to share across a web server's threads. Calls take turns, and the engine releases the GIL while it runs, so other threads keep going. With asyncio, call it directly: a local engine never touches the network.
The docs, in both languages
Every example in the docs now has a TypeScript tab and a Python tab, and the Python examples run against the released package like the TypeScript ones, printing what the page says they print. The tutorial has all 15 chapters in Python, and there are Python versions of the recipes for the Claude Agent SDK and the Claude Messages API, with their tests in the repo. Pick a language once and the site remembers it.
For coding agents, the limitr-py skill covers the Python SDK, next to the policy and Stof skills. It's in the Claude
Code plugin (/plugin marketplace add dev-formata-io/limitr) and in the repo's
content/ folder.
Start with the quickstart, or the Python SDK reference.
