xenovia-sdk) gates agent tool calls, database writes, API requests, and any other action against Xenovia policy — without proxying an LLM call. Use it alongside proxy mode for end-to-end governance.
Install:
How it works
The SDK sends an action intent — a capability string plus a payload — to the Xenovia backend viaPOST /v1/execute. The backend evaluates your Rego policy and returns a typed decision. Your function executes locally if allowed. No LLM is involved.
Initialise the client
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | required | Xenovia API key (xe_...) |
endpoint | str | https://api.xenovia.io | Xenovia API base URL |
default_env | str | "prod" | Environment label |
raise_on_block | bool | False | Raise XenoviaBlockedError on block |
timeout | int | 5 | HTTP request timeout (seconds) |
auto_session | bool | False | Auto-generate and reuse session UUIDs |
debug | bool | False | Print decision logs to stdout |
identity_id | str | env XENOVIA_AGENT_ID or "default-agent" | Actor identity |
identity_type | str | "agent" | Identity type label |
unreachable_mode | str | "error" | Behaviour when backend unreachable |
allow_insecure_http | bool | False | Allow HTTP (localhost/loopback only) |
unreachable_mode values:
| Mode | Behaviour |
|---|---|
"error" | Raise XenoviaUnreachableError (fail closed) |
"allow" | Return a synthetic success response (fail open) |
"block" | Return a synthetic blocked response |
execute() — one-off policy check
capability is omitted, the SDK infers it from the caller’s module and function name (module.function_name) using frame inspection.
@guard() — decorator
Wraps a function with policy-aware gating. In enforce mode (default), the function body does not execute if the policy denies the action.
XenoviaResponse. Access .result for the function’s return value when allowed:
| Mode | Behaviour |
|---|---|
"enforce" | Function body does not execute if denied or if the backend call fails |
"observe" | Function always executes locally; would-block decisions are logged |
- Explicit
payloadkeyword argument - Single
dictpositional argument - Scalar argument →
{"value": arg} - Multiple args → all args as a dict
- No args →
{}
XenoviaResponse — response object
Session handling
Withauto_session=True, the SDK generates a session UUID on the first call and reuses it for subsequent calls on the same client instance:
session_id to override auto-session:
Error handling
Wire format
The SDK sendsPOST /v1/execute with:
Security
- HTTPS is enforced unless
allow_insecure_http=True(restricted to localhost/loopback only). - The API key is sent only in the
Authorization: Bearer xe_...header — never in payloads or logs. - No payload logging in debug mode; only the decision outcome and trace ID are printed.