Get started

Secure your first Python agent.

This example registers one agent, discovers its callable tools, syncs three policies and blocks execution before an unauthorized tool runs.

1. Install

pip install quasentra

2. Configure

QUASENTRA_API_KEY=ask_live_...
QUASENTRA_URL=https://quasentra.com

3. Wrap the agent factory

import os
from quasentra import Quasentra

class InvoiceAgent:
    def __init__(self, tools):
        self.tools = tools

def invoice_read(invoice_id: str) -> dict:
    """Read an invoice without changing it."""
    return {"invoice_id": invoice_id, "status": "open"}

def invoice_pay(invoice_id: str, amount: int) -> str:
    """Pay an invoice; this needs human approval."""
    return f"Paid {amount} against {invoice_id}"

def invoice_delete(invoice_id: str) -> str:
    """Delete an invoice; this operation is denied."""
    return f"Deleted {invoice_id}"

security = Quasentra(
    api_key=os.environ["QUASENTRA_API_KEY"],
    base_url=os.getenv("QUASENTRA_URL", "https://quasentra.com"),
)

@security.protect(
    "invoice-agent",
    permissions={
        "invoice.read": "ALLOW",
        "invoice.pay": "REQUIRE_APPROVAL",
        "invoice.delete": "DENY",
    },
)
def build_agent():
    return InvoiceAgent(tools=[invoice_read, invoice_pay, invoice_delete])

agent = build_agent()

4. Verify behavior

The dashboard will show invoice-agent, its three discovered tools and the code-defined policy. Unknown tools remain denied.

Keep the SDK object alive for the application process and close it during graceful shutdown.