Skip to main content

Runtime authorization for AI agents — Python SDK

Project description

useveto

Runtime authorization for AI agents — Python SDK.

PyPI License: MIT Python

What is Veto?

Veto intercepts every tool call your AI agent makes, evaluates it against your policies, and decides: allow, deny, or escalate. Sub-10ms. Default deny.

  • Default deny — no matching policy = blocked
  • Full audit trail — every decision logged
  • Edge-first — powered by Cloudflare Workers
  • Sync + async — both clients included

Install

pip install useveto

Quick Start

from veto import VetoClient

client = VetoClient(api_key="veto_...")

# Check if an agent can perform an action
result = client.authorize("agent-uuid", "file.write", {"path": "/etc/passwd"})

if not result.allowed:
    print(f"Blocked: {result.reason}")

Async

from veto import AsyncVetoClient

async with AsyncVetoClient(api_key="veto_...") as client:
    result = await client.authorize("agent-uuid", "send_email", {
        "to": "user@example.com",
        "subject": "Refund confirmation",
    })

LangChain Integration

from veto import VetoClient, VetoError

veto = VetoClient(api_key="veto_...")

def veto_tool_wrapper(tool_func, tool_name: str, agent_id: str):
    """Wrap any LangChain tool with Veto authorization."""
    def wrapper(*args, **kwargs):
        result = veto.authorize(agent_id, tool_name, kwargs)
        if not result.allowed:
            return f"Authorization denied: {result.reason}"
        return tool_func(*args, **kwargs)
    wrapper.__name__ = tool_func.__name__
    wrapper.__doc__ = tool_func.__doc__
    return wrapper

CrewAI Integration

from veto import VetoClient

veto = VetoClient(api_key="veto_...")

def before_tool_callback(agent_id: str):
    def callback(tool_name: str, tool_input: dict) -> bool:
        result = veto.authorize(agent_id, tool_name, tool_input)
        return result.allowed
    return callback

API Reference

VetoClient / AsyncVetoClient

client = VetoClient(
    api_key="veto_...",       # required
    endpoint="https://api.veto.tools",  # optional
    timeout=5.0,              # optional, seconds
)

Authorization

client.authorize(agent_id, tool_name, parameters={}) -> AuthorizationResult

Agents

client.create_agent(CreateAgentInput(name="Bot", description="...")) -> Agent
client.list_agents() -> List[Agent]
client.get_agent(agent_id) -> Agent
client.delete_agent(agent_id) -> None

Policies

client.create_policy(CreatePolicyInput(
    agent_id="...",
    name="Allow reads",
    rules=[PolicyRule(type="tool_allowlist", tools=["file.read"])],
    priority=10,
)) -> Policy

client.list_policies(agent_id=None) -> List[Policy]
client.get_policy(policy_id) -> Policy
client.update_policy(policy_id, UpdatePolicyInput(name="New name")) -> Policy
client.delete_policy(policy_id) -> None

Audit Logs

client.query_audit_log(
    agent_id=None,
    tool_name=None,
    result=None,  # "allowed" | "denied" | "escalated"
    limit=100,
    offset=0,
) -> PaginatedAuditLogResponse

Error Handling

from veto import VetoError, UnauthorizedError, RateLimitError

try:
    result = client.authorize("agent", "tool")
except RateLimitError as e:
    print(f"Retry after {e.retry_after_ms}ms")
except UnauthorizedError:
    print("Invalid API key")
except VetoError as e:
    print(f"{e.code}: {e}")

Context Manager

# Sync
with VetoClient(api_key="veto_...") as client:
    result = client.authorize("agent-1", "file.read")

# Async
async with AsyncVetoClient(api_key="veto_...") as client:
    result = await client.authorize("agent-1", "file.read")

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

useveto-0.1.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

useveto-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file useveto-0.1.0.tar.gz.

File metadata

  • Download URL: useveto-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for useveto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7136161f69119318c80780937138b5a343cc3d83329e18e6319c9659b60f8faa
MD5 82dde42adaca7cf562f15f4d7fd1c7fc
BLAKE2b-256 678608ed6ecb397e573e1c9ee80ace659e55a03091f1bb5eb2d2f9cde9b1a2c2

See more details on using hashes here.

File details

Details for the file useveto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: useveto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for useveto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ebd903e6e2237c5e9f054111124c099ca0ce4a877f2e3e7db13f938f52ec36a
MD5 a3f1782ec4d99af16c41dd6838c03a34
BLAKE2b-256 d6301802c86de53dc2285d121fcca9ff811c9572d963e6b68478a0ed3396c2bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page