TrustFlow Python SDK — Governance-as-a-Service for AI agent transactions
Project description
TrustFlow Python SDK
Governance-as-a-Service for AI Agent Transactions
Evaluate transaction risk, enforce compliance, and trace decisions — in one API call.
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_keyto 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
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 trustflow-1.0.0.tar.gz.
File metadata
- Download URL: trustflow-1.0.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5e72733865a49d3efc5a917892e2585b8fb34809e11cc7082c747409da383f0
|
|
| MD5 |
1bd725ce35457ee47b8dab38728e5548
|
|
| BLAKE2b-256 |
f58b9c9a343dbe7dfb96feac2a7cbc226b68ed43a6a9e2f9800f0305bbe3bfca
|
File details
Details for the file trustflow-1.0.0-py3-none-any.whl.
File metadata
- Download URL: trustflow-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
487452a2bce03101e314567993bfef94fd7861b57f31ef57840b727d3406bbfc
|
|
| MD5 |
718a2f59417c4755055224f4fbad7b48
|
|
| BLAKE2b-256 |
c8677c17995fdad9063e2e5a64ec36fe5d525b52680cc0795bb92a325e5b4077
|