Official Python SDK for the TrustGuard runtime evaluate API (POST /v1/evaluate)
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trustguard_sdk-0.1.3.tar.gz.
File metadata
- Download URL: trustguard_sdk-0.1.3.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c662781232e8195d619e6656e00f6f88df3ff4666ec241089fa0c00df13d196
|
|
| MD5 |
520f76bb9b72290f826b1e814a737396
|
|
| BLAKE2b-256 |
2fa3ecba22dfd75df14e764cfafcd3e02ffcecfccc64cd96ce83c2071dda570f
|
Provenance
The following attestation bundles were made for trustguard_sdk-0.1.3.tar.gz:
Publisher:
publish-python.yml on NeuralTrust/trustguard-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trustguard_sdk-0.1.3.tar.gz -
Subject digest:
0c662781232e8195d619e6656e00f6f88df3ff4666ec241089fa0c00df13d196 - Sigstore transparency entry: 2232499945
- Sigstore integration time:
-
Permalink:
NeuralTrust/trustguard-sdk@672e0567333b38ea8d3129832241e74ec70cbad9 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/NeuralTrust
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@672e0567333b38ea8d3129832241e74ec70cbad9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file trustguard_sdk-0.1.3-py3-none-any.whl.
File metadata
- Download URL: trustguard_sdk-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c017df9b09d7305161c256acb0abd2532e4915bda9c3bce9312603b7101ccca1
|
|
| MD5 |
2bf19360b624bef67e3664f556890955
|
|
| BLAKE2b-256 |
908c88e870523b4c34b75c45c70278bd9631cf519de0a4d0fcfd73b4c0bc825b
|
Provenance
The following attestation bundles were made for trustguard_sdk-0.1.3-py3-none-any.whl:
Publisher:
publish-python.yml on NeuralTrust/trustguard-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trustguard_sdk-0.1.3-py3-none-any.whl -
Subject digest:
c017df9b09d7305161c256acb0abd2532e4915bda9c3bce9312603b7101ccca1 - Sigstore transparency entry: 2232500590
- Sigstore integration time:
-
Permalink:
NeuralTrust/trustguard-sdk@672e0567333b38ea8d3129832241e74ec70cbad9 -
Branch / Tag:
refs/tags/python-v0.1.3 - Owner: https://github.com/NeuralTrust
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@672e0567333b38ea8d3129832241e74ec70cbad9 -
Trigger Event:
push
-
Statement type: