Metadata-Version: 2.4
Name: lelu-agent-auth-sdk
Version: 0.3.6
Summary: Python SDK for Lelu — framework-agnostic authorization engine for AI agents with confidence-aware controls, Docker deployment, and human-in-the-loop workflows
Project-URL: Homepage, https://lelu-ai.com/
Project-URL: Repository, https://github.com/lelu-auth/lelu
Author-email: Abenezer Getachew <abenezer.getachew@lelu-ai.com>
License: MIT
Keywords: ai-agents,audit-trail,auth,authorization,crewai,docker,fastapi,human-in-the-loop,langchain,langgraph,permissions,policy-engine,risk-evaluation
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.7.0
Provides-Extra: dev
Requires-Dist: mypy>=1.10.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30.0; extra == 'dev'
Requires-Dist: pytest>=8.2.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.111.0; extra == 'fastapi'
Provides-Extra: langgraph
Requires-Dist: langgraph>=0.1.0; extra == 'langgraph'
Description-Content-Type: text/markdown

# Lelu · Python SDK

Python client for [Lelu](https://github.com/lelu-auth/lelu) — the confidence-aware authorization engine for autonomous AI agents.

**Author:** Abenezer Getachew

## Installation

```bash
pip install lelu-agent-auth-sdk
```

Or run the public Lelu engine image:

```bash
docker pull abenezer0923/lelu-engine:latest
docker run --rm -p 8083:8080 abenezer0923/lelu-engine:latest
```

## Quick start

### Option 1: Use Hosted Engine (Recommended)

Connect to the hosted Lelu engine for instant setup:

```python
import asyncio
from lelu import LeluClient, AgentAuthRequest, AgentContext

async def main():
    async with LeluClient(base_url="https://lelu-engine.onrender.com") as client:
        result = await client.agent_authorize(AgentAuthRequest(
            actor="invoice_bot",
            action="invoice:create",
            context=AgentContext(
                confidence=0.92,
                acting_for="user_123",
            ),
        ))
        print(result.allowed, result.reason)

asyncio.run(main())
```

### Option 2: Run Locally

For development, you can run the engine locally:

```python
import asyncio
from lelu import LeluClient, AgentAuthRequest, AgentContext

async def main():
    async with LeluClient(base_url="http://localhost:8082") as client:
        result = await client.agent_authorize(AgentAuthRequest(
            actor="invoice_bot",
            action="invoice:create",
            context=AgentContext(
                confidence=0.92,
                acting_for="user_123",
            ),
        ))
        print(result.allowed, result.reason)

asyncio.run(main())
```

Start the local engine with Docker:

```bash
docker compose up -d
```

## 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
