Installation
Terminal
$ pip install openleash-sdk
Quick Example
Request authorization before performing a risky action. The SDK signs the request with your agent's Ed25519 private key and returns a decision with an optional proof token.
authorize.py
from openleash import (
authorize,
generate_ed25519_keypair,
)
# Generate a keypair (do this once, store the keys)
public_key, private_key = generate_ed25519_keypair()
# Request authorization for an action
result = authorize(
base_url="http://localhost:8787",
agent_id="agent-uuid",
private_key=private_key,
request={
"action": "purchase",
"resource": "office-supplies",
"context": {"amount": 42.00},
},
)
# result.decision: "ALLOW" | "DENY" | "REQUIRE_APPROVAL" | ...
# result.proof_token: signed PASETO v4.public token (if allowed)
Available Functions
The Python SDK provides 13 functions covering the full agent authorization lifecycle. All functions use snake_case naming:
authorize— request an authorization decision for an actionsign_request— sign an HTTP request body with Ed25519register_agent— register an agent with the OpenLeash serververify_proof_offline— verify a proof token locally using the public keyverify_proof_online— verify a proof token via the server APIgenerate_ed25519_keypair— generate a new Ed25519 signing keypaircreate_approval_request— create a pending approval requestget_approval_request— fetch the status of an approval requestpoll_approval_request— poll until an approval request is resolvedget_agent— retrieve agent details from the serverlist_policies— list all policies visible to the agentlist_approval_requests— list all approval requests for the agentpropose_policy— propose a new policy for owner review
Proof Verification
Counterparties can verify proof tokens offline without contacting the OpenLeash server. The token is a PASETO v4.public token signed with Ed25519. Note: pyseto requires PEM-formatted keys.
verify.py
from openleash import verify_proof_offline
claims = verify_proof_offline(
proof_token=proof_token,
public_key=owner_public_key,
)
# claims["action"], claims["resource"], claims["decision"], claims["exp"]