Concepts
Client SDKs
Lelu offers official client SDKs for TypeScript, Python, and Go. These SDKs provide a type-safe, ergonomic way to interact with the Lelu Engine from agents and backend services.
Why use the SDK?
While you can call the REST API directly, the SDKs handle several complex tasks automatically:
- Long-polling: Automatically waits for human approval when a request is queued.
- Type Safety: Full TypeScript definitions and Python type hints.
- Retries: Built-in exponential backoff for network failures.
- Framework Integrations: Drop-in middleware for LangChain, AutoGPT, and Express.
TypeScript SDK
Installation
npm install @lelu-auth/lelu
Usage
import { LeluClient } from "@lelu-auth/lelu";
const lelu = new LeluClient({
baseUrl: "http://localhost:8082",
apiKey: process.env.LELU_API_KEY,
});
// This call will block if human approval is required
const decision = await lelu.authorize({
action: "delete_user",
confidence: 0.75,
waitForApproval: true // Default is true
});
if (decision.allowed) {
console.log("Action approved!");
}Python SDK
Installation
pip install lelu-agent-auth-sdk
Usage
from lelu import LeluClient
lelu = LeluClient(
base_url="http://localhost:8082",
api_key="YOUR_API_KEY"
)
decision = lelu.authorize(
action="delete_user",
confidence=0.75
)
if decision.requires_human_review:
# Block until the human clicks Approve/Deny in the UI
decision.wait()
if decision.allowed:
print("Action approved!")Go SDK
Installation
go get github.com/lelu-auth/lelu/sdk/go
Usage
package main
import (
"context"
"fmt"
lelu "github.com/lelu-auth/lelu/sdk/go"
)
func main() {
client := lelu.NewClient(lelu.ClientConfig{
BaseURL: "http://localhost:8082",
APIKey: "your-api-key",
})
decision, err := client.AgentAuthorize(context.Background(), lelu.AgentAuthRequest{
Actor: "invoice_bot",
Action: "approve_refunds",
Confidence: 0.92,
ActingFor: "user_123",
})
if err != nil {
panic(err)
}
fmt.Println("allowed:", decision.Allowed, "reason:", decision.Reason)
}| Method | Description |
|---|---|
| Authorize | Human authorization via /v1/authorize |
| AgentAuthorize | Confidence-aware agent authorization via /v1/agent/authorize |
| MintToken | Mint JIT token via /v1/tokens/mint |
| RevokeToken | Revoke token via DELETE /v1/tokens/{id} |
| IsHealthy | Engine health check via /healthz |