TrustGuard Python SDK
Official Python client for the TrustGuard runtime evaluate API (POST /v1/evaluate). Configure a base URL and an API key, send the payload you want evaluated, and act on the verdict: TrustGuard detects, you enforce.
Install
pip install trustguard-sdk
Requires Python 3.9+. The only dependency is httpx.
Usage
from trustguard import TrustGuard
client = TrustGuard("https://guard.neuraltrust.ai", api_key="YOUR_API_KEY")
response = client.guard({"input": "user text to evaluate"})
if response.is_blocked:
# block the request
...
client.close() # or use the context manager below
As a context manager:
with TrustGuard("https://guard.neuraltrust.ai", api_key="YOUR_API_KEY") as client:
response = client.guard({"input": "user text"})
Async
from trustguard import AsyncTrustGuard
async with AsyncTrustGuard("https://guard.neuraltrust.ai", api_key="YOUR_API_KEY") as client:
response = await client.guard({"input": "user text"})
Options
response = client.guard(
{"input": "user text"},
direction="output", # "input" (default) or "output"
protocol="llm", # "all" (default), "llm", "mcp", or "a2a"
session_id="conversation-42", # groups multi-turn traffic
consumer_id="user-7", # the end user behind the request
attributes={"content_type": "text/plain"}, # routing hints
)
Attachments
Documents are base64-encoded into payload.attachments for file-aware plugins (or pass a url for the server to fetch):
from trustguard import Attachment
response = client.guard(
{"input": "summarize this file"},
attachments=[Attachment(filename="doc.pdf", content_type="application/pdf", data=pdf_bytes)],
)
Response
| Field | Meaning |
|---|---|
status |
Most restrictive verdict: allow, block, transform, report, or empty when omitted. is_blocked is True when it is block |
findings |
Nested findings: source / signal / outcome / evidence (observational runs omit signal/outcome) |
transformed_payload |
The payload as rewritten by in-flight masking, None when untouched |
trace_id / request_id |
Correlation ids for TrustGuard telemetry |
Errors
Non-2xx responses raise TrustGuardAPIError with status_code, message, trace_id and request_id. Transport failures (timeouts, connection errors) raise the underlying httpx exceptions. The default timeout is 10 seconds (timeout= to change it); pass http_client= to supply your own configured httpx.Client / httpx.AsyncClient.
Development
pip install -e '.[dev]'
ruff check .
pytest
Release files for trustguard-sdk 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| trustguard_sdk-0.1.3.tar.gz | 19.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| trustguard_sdk-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.1 kB
Release files / trustguard_sdk-0.1.3.tar.gz
| Download URL | trustguard_sdk-0.1.3.tar.gz |
|---|---|
| Size | 19.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c662781232e8195d619e6656e00f6f88df3ff4666ec241089fa0c00df13d196
|
|
BLAKE2b-256 checksum How to use checksums |
2fa3ecba22dfd75df14e764cfafcd3e02ffcecfccc64cd96ce83c2071dda570f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / trustguard_sdk-0.1.3-py3-none-any.whl
| Download URL | trustguard_sdk-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c017df9b09d7305161c256acb0abd2532e4915bda9c3bce9312603b7101ccca1
|
|
BLAKE2b-256 checksum How to use checksums |
908c88e870523b4c34b75c45c70278bd9631cf519de0a4d0fcfd73b4c0bc825b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency log