Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trustguard_sdk-0.1.3.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trustguard_sdk-0.1.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

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

Hashes for trustguard_sdk-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0c662781232e8195d619e6656e00f6f88df3ff4666ec241089fa0c00df13d196
MD5 520f76bb9b72290f826b1e814a737396
BLAKE2b-256 2fa3ecba22dfd75df14e764cfafcd3e02ffcecfccc64cd96ce83c2071dda570f

See more details on using hashes here.

Provenance

The following attestation bundles were made for trustguard_sdk-0.1.3.tar.gz:

Publisher: publish-python.yml on NeuralTrust/trustguard-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for trustguard_sdk-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c017df9b09d7305161c256acb0abd2532e4915bda9c3bce9312603b7101ccca1
MD5 2bf19360b624bef67e3664f556890955
BLAKE2b-256 908c88e870523b4c34b75c45c70278bd9631cf519de0a4d0fcfd73b4c0bc825b

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page