> ## 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.

## Coverage

| Surface    | Monitor | Block | Redact |
| ---------- | :-----: | :---: | :----: |
| LLM input  |    ✅    |   ⚠️  |   ⚠️   |
| LLM output |    ✅    |   ⚠️  |   ⚠️   |
| Tool-level |    ⚠️   |   ⚠️  |   ⚠️   |

**Ask** — `status` is advisory: nothing prompts anyone unless your code does.

**Use it when** the model call lives in your Python code and the policy decision
needs context only the application has — the authenticated user, the tenant, the
retrieved document. **Not as your only defence when** you need a guarantee a
developer cannot bypass by forgetting a branch; that is a
[gateway](/trustguard/integrations/trustgate) collector.

⚠️ TrustGuard returns the verdict, your code enforces it. Code that logs a
`block` and calls the model anyway is monitoring; ignoring `transformed_payload`
forwards unmasked data. Tool-level coverage means calling evaluate with
`protocol: "mcp"` around your tool dispatch.

**Limits.** Coverage is per call site. If that worries you, use
[Python middleware](/trustguard/integrations/python-middleware).

Full comparison: [Coverage](/trustguard/integrations/coverage).

```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)")
```
