> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> trustguard-sdk — guard() with direction input/output.

Create an API key on the collector first. Set `direction` on every call (`input` before
the model, `output` after). Defaults to `input` if omitted.

```bash theme={null}
pip install trustguard-sdk
```

```python theme={null}
from trustguard import TrustGuard

client = TrustGuard("<your-trustguard-url>", api_key="<collector-api-key>")

inbound = client.guard(
    {"input": user_input},
    direction="input",
    consumer_id="alex@acme.com",
    session_id="sess-123",
)
if inbound.is_blocked:
    raise PermissionError("Blocked by TrustGuard (input)")
prompt = inbound.transformed_payload or {"input": user_input}

# … model call …

outbound = client.guard(
    {"input": model_completion},
    direction="output",
    consumer_id="alex@acme.com",
    session_id="sess-123",
)
if outbound.is_blocked:
    raise PermissionError("Blocked by TrustGuard (output)")
```
