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

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.5
File Size Uploaded Provenance Actions
trustguard_sdk-0.1.5.tar.gz 20.1 kB With provenance Details for trustguard_sdk-0.1.5.tar.gz

Built distribution (wheel)

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

Total release size: 27.6 kB

Release files / trustguard_sdk-0.1.5.tar.gz

Download URL trustguard_sdk-0.1.5.tar.gz
Size 20.1 kB
Tags Source
SHA-256 checksum
How to use checksums
516f283bed8c28e25f432580f96661c5376943405065f8941c45a991acc18fd0
BLAKE2b-256 checksum
How to use checksums
67cb702c0ed8793229151144e4d394f1b5066203f2d5e17bc889aa67460bfa74
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.5-py3-none-any.whl

Download URL trustguard_sdk-0.1.5-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
075da7d0fdd40b2d5d4a34de4695e9f4210b60ef115ca9b163988da593884df1
BLAKE2b-256 checksum
How to use checksums
04ee5ccdd6aa95ced23f01a8a91dd22cca1b1152ab9cd11dd0fe5da8a69b305a
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.5

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