Skip to main content

TrustFlow Python SDK

Governance-as-a-Service for AI Agent Transactions

Evaluate transaction risk, enforce compliance, and trace decisions — in one API call.

PyPI Python

Install

pip install trustflow

Quick Start

from trustflow import TrustFlowClient

client = TrustFlowClient(api_key="tf_live_a1b2c3...")

# Evaluate a transaction
result = client.evaluate(
    amount=349.99,
    category="electronics",
    merchant_id="amazon_bot",
    user_id="user_456",
)

print(result.decision)    # "APPROVED"
print(result.risk_score)  # 32.5
print(result.risk_level)  # "MEDIUM"
print(result.trace_id)    # "tf-a8f3c9b12e04"
print(result.factors)     # 7 risk factors with scores and explanations

Features

  • Automatic retry with exponential backoff
  • Typed responses — full IDE autocompletion
  • Agent Identity — sign requests with Ed25519/JWS/HMAC for verified agent transactions
  • Idempotency — pass idempotency_key to prevent duplicate evaluations
  • Sandbox mode — use tf_test_ keys for deterministic testing

Agent Identity Verification

For verified agent transactions (Visa Trusted Agent Protocol, Google AP2, x402):

from trustflow import TrustFlowClient, generate_ed25519_keypair, sign_ed25519

client = TrustFlowClient(api_key="tf_live_...")

# One-time: generate a keypair and register the public key with TrustFlow
priv_b64, pub_b64 = generate_ed25519_keypair()
# POST /v1/identity/issuers with pub_b64 to register your issuer

# Per-transaction: sign the canonical payload
identity = sign_ed25519(
    private_key_b64=priv_b64,
    agent_id="my-shopping-agent-v2",
    issuer="my-company.example.com",
    amount=349.99,
    currency="USD",
    merchant_id="amazon_bot",
    user_id="user_456",
)

result = client.evaluate(
    amount=349.99,
    category="electronics",
    merchant_id="amazon_bot",
    user_id="user_456",
    agent_identity=identity,
)

# Verified agents get lower risk scores
print(result.agent_identity)  # {"status": "verified", "scheme": "ed25519", ...}

Configuration

# Custom base URL
client = TrustFlowClient(
    api_key="tf_live_...",
    base_url="https://your-instance.example.com",
    timeout=10.0,
    max_retries=3,
)

API Reference

Full documentation: api.trust-flow.dev/docs

Get Your API Key

curl -X POST https://api.trust-flow.dev/signup \
  -H "Content-Type: application/json" \
  -d '{"name": "Your Name", "email": "you@company.com"}'

Free tier: 100 evaluations/hour, 1,000/day. No credit card required.

License

MIT

Metadata

Release files for trustflow 1.0.0

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

Source distribution (sdist)

Source distribution for trustflow 1.0.0
File Size Uploaded Provenance
trustflow-1.0.0.tar.gz 8.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for trustflow 1.0.0
File Interpreter ABI Platform
trustflow-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / trustflow-1.0.0.tar.gz

Download URL trustflow-1.0.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a5e72733865a49d3efc5a917892e2585b8fb34809e11cc7082c747409da383f0
BLAKE2b-256 checksum
How to use checksums
f58b9c9a343dbe7dfb96feac2a7cbc226b68ed43a6a9e2f9800f0305bbe3bfca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / trustflow-1.0.0-py3-none-any.whl

Download URL trustflow-1.0.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
487452a2bce03101e314567993bfef94fd7861b57f31ef57840b727d3406bbfc
BLAKE2b-256 checksum
How to use checksums
c8677c17995fdad9063e2e5a64ec36fe5d525b52680cc0795bb92a325e5b4077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for trustflow 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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