Skip to main content

TrustGuard Python SDK

PyPI Documentation · Node.js package · Go module · GitHub

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.

Documentation

The full guide is at docs.neuraltrust.ai: setting up the collector and its key, guarding input and output, configuration, the attributes an evaluation carries, and troubleshooting. The Evaluate API is the contract every SDK wraps, and SDKs says when to reach for TrustGuard and when for TrustGate.

The same client in other languages: Node.js, Go. Source, examples and issues: github.com/NeuralTrust/trustguard-sdk.

Development

pip install -e '.[dev]'
ruff check .
pytest

Metadata

Release files for trustguard-sdk 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trustguard-sdk 0.1.4
File Size Uploaded Provenance Actions
trustguard_sdk-0.1.4.tar.gz 20.1 kB With provenance Details for trustguard_sdk-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trustguard-sdk 0.1.4
File Interpreter ABI Platform Actions
trustguard_sdk-0.1.4-py3-none-any.whl Python 3 none any Details for trustguard_sdk-0.1.4-py3-none-any.whl

Total release size: 27.6 kB

Release files / trustguard_sdk-0.1.4.tar.gz

Download URL trustguard_sdk-0.1.4.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5141f1aef54bac4bb237e67960caa77ba72525fe97fc2a8b4cff110e3aa37dcc
BLAKE2b-256 checksum
How to use checksums
f5313debe8f6f66a668514228d1aa420e3fd4ba915b7cc77e0d4519bf346e2b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Sep 23, 2026.

Transparency log

Release files / trustguard_sdk-0.1.4-py3-none-any.whl

Download URL trustguard_sdk-0.1.4-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60b69ad5b77712df8d7388679b692e388462234260019405d080e154cfa2673e
BLAKE2b-256 checksum
How to use checksums
86afc4e65e4368aba6c94402340564e0ea9312692ea071b4153c00b94e3aa706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.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 Sep 23, 2026.

Transparency log

Security for trustguard-sdk 0.1.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for trustguard_sdk-0.1.4.tar.gz

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 Sep 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page