Lelu · Python SDK
Python client for Lelu — the confidence-aware authorization engine for autonomous AI agents.
Author: Abenezer Getachew
Maintainer: Abenezer Getachew
Installation
pip install lelu-agent-auth-sdk
Quick start
Option 1: Zero-config local (recommended)
Run the local engine once — it self-generates its key and policy in ~/.lelu,
no account needed:
npx -y lelu-mcp start
Then create one shared instance and import it everywhere. With no arguments,
lelu() discovers that engine automatically:
import asyncio
from lelu import lelu
auth = lelu(actor="invoice_bot") # zero-config: finds the local engine
async def main():
result = await auth.authorize(tool="invoice:create")
if result.decision == "allow":
... # proceed
elif result.decision == "human_review":
# Queued for a human. Don't just wait for "approved" and then act —
# an approval is bound to the request it approved, so pass the same
# request back and let the engine confirm nothing changed.
outcome = await auth.wait_and_redeem(result, tool="invoice:create")
if not outcome.allowed:
raise PermissionError(outcome.reason)
... # proceed
else:
raise PermissionError(result.reason)
asyncio.run(main())
The instance exposes the full client as auth.api (tokens, review queue,
audit, policies): await auth.api.mint_token(...).
Option 2: Self-hosted or cloud engine
Point the same factory at any engine with explicit config — or set
LELU_BASE_URL / LELU_API_KEY and keep calling lelu() with no arguments:
auth = lelu(
base_url="https://your-engine.example.com",
api_key=os.environ["LELU_API_KEY"],
actor="invoice_bot",
)
LeluClient(...) from earlier versions keeps working unchanged — auth.api
is that same client.
API
| Method | Description |
|---|---|
agent_authorize(req) |
Confidence-aware agent authorization |
authorize(req) |
Human RBAC authorization |
mint_token(req) |
Mint a JIT-scoped JWT |
revoke_token(token_id) |
Revoke a token immediately |
is_healthy() |
Health-check the engine |
License
MIT
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 lelu_agent_auth_sdk-0.4.4.tar.gz.
File metadata
- Download URL: lelu_agent_auth_sdk-0.4.4.tar.gz
- Upload date:
- Size: 58.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5badd8483e4085b050efdd692d448ba2fe6862d77fd0b735dbb3a14d9096c97
|
|
| MD5 |
7a86f36143110009fc94a3ce9f212c44
|
|
| BLAKE2b-256 |
469833644f31c26cac2bbf2cd1d2527b4b315f2b044bac9e2b44b2ac2280db94
|
File details
Details for the file lelu_agent_auth_sdk-0.4.4-py3-none-any.whl.
File metadata
- Download URL: lelu_agent_auth_sdk-0.4.4-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880f08ee7a830a1f55aba821f0f2cedd492bb1d1b2c7f93bc1b046c856fbd5a6
|
|
| MD5 |
91c12565a860f9a95a4d23f08747bd11
|
|
| BLAKE2b-256 |
cf6e5b238c038a0b97fb3be538069c39cf21f86d9e9ff8e3fb52e1f8a16a3a65
|