Python SDK for the Trust OS Decision Verification API
Project description
Trust OS Python SDK
Python SDK for the Trust OS Decision Verification API.
Verify high-impact decisions before execution — payments, treasury operations, AI agent actions, and compliance workflows — with a single function call.
Links
| Resource | URL |
|---|---|
| Website | https://trust-os.io |
| Developer Docs | https://trust-os.io/docs |
| API Reference | https://trust-os.io/docs/api |
| Playground | https://demo.trust-os.io |
| Operations Demo | https://ops.trust-os.io |
| GitHub Organization | https://github.com/trustos-trustfolio |
| OpenAPI Spec | https://trust-os.io/openapi.json |
Installation
PyPI release coming soon. For now, install directly from GitHub once the repository is published:
pip install git+https://github.com/trustos-trustfolio/trustos-python-sdk.git
Once published to PyPI:
pip install trustos
Quick Start
from trustos import TrustOSClient
client = TrustOSClient(api_key="YOUR_API_KEY")
result = client.verify_decision({
"action": "stablecoin_transfer",
"amount": 50000,
"currency": "USDC",
"destination": "wallet_abc",
})
print(result["recommendation"]) # APPROVE | REVIEW | DENY
print(result["proof_hash"]) # SHA-256: 0x4a3f...9c2b
Environment Variables
Store your API key as an environment variable instead of hardcoding it:
# .env (never commit this file)
TRUSTOS_API_KEY=your_api_key_here
The client reads TRUSTOS_API_KEY automatically when no api_key= argument is provided:
from trustos import TrustOSClient
client = TrustOSClient() # reads TRUSTOS_API_KEY from environment
Examples
Stablecoin Payment
from trustos import TrustOSClient
client = TrustOSClient()
result = client.verify_decision({
"action": "stablecoin_transfer",
"amount": 250000,
"currency": "USDC",
"destination": "wallet_0x4f3b9c2a8d1e6f5a",
"source": "Payment API",
"priority": "High",
"metadata": {"region": "SG", "workflow": "merchant_settlement"},
})
if result["recommendation"] == "APPROVE":
# safe to execute the transfer
print("Approved:", result["decision_id"])
elif result["recommendation"] == "REVIEW":
# queue for human review
queue_for_review(result["decision_id"])
else:
# block the transfer
raise ValueError("Payment denied by Trust OS policy")
Treasury Disbursement
result = client.verify_decision({
"action": "treasury_disbursement",
"amount": 1_000_000,
"currency": "USDC",
"destination": "dao_multisig_0x91a3b7c2",
"source": "governance-system",
"priority": "High",
})
AI Agent Action
result = client.verify_decision({
"action": "execute_tool",
"destination": "database_write",
"source": "agent-framework",
"priority": "High",
"metadata": {"tool": "write_record", "agent_id": "agent_alpha_001"},
})
More complete examples are in the examples/ directory.
API Reference
TrustOSClient(api_key=None, base_url=None, timeout=10.0)
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | None |
None |
API key. Falls back to TRUSTOS_API_KEY env var. |
base_url |
str | None |
Production gateway | Override the API base URL. |
timeout |
float |
10.0 |
Request timeout in seconds. |
Raises ValueError if no API key is found.
client.verify_decision(payload: dict) -> dict
Submit a decision for verification. Returns the parsed JSON response.
Request fields:
| Field | Type | Required | Description |
|---|---|---|---|
action |
string | Yes | Decision action type |
amount |
number | No | Transaction amount |
currency |
string | No | Currency or asset symbol |
destination |
string | No | Target wallet or account |
source |
string | No | Originating system |
priority |
string | No | "High", "Medium", or "Low" |
metadata |
object | No | Additional context fields |
Response fields:
| Field | Type | Description |
|---|---|---|
decision_id |
string | Unique identifier — store for audit trail |
recommendation |
string | APPROVE, REVIEW, or DENY |
risk_score |
number | 0.0 (no risk) to 1.0 (maximum) |
risk_level |
string | LOW, MEDIUM, or HIGH |
policy |
string | Policy name and version applied |
proof_hash |
string | SHA-256 cryptographic proof |
verified |
boolean | True when cryptographically verified |
latency_ms |
number | Evaluation latency in milliseconds |
client.verify(payload: dict) -> dict
Alias for verify_decision().
Error Handling
from trustos import TrustOSClient, TrustOSError
client = TrustOSClient()
try:
result = client.verify_decision({"action": "stablecoin_transfer"})
except TrustOSError as e:
print(f"Status code: {e.status_code}")
print(f"Response body: {e.response_body}")
print(f"Message: {e}")
TrustOSError is raised on:
- Non-2xx HTTP responses (401 unauthorized, 429 rate limit, 500 server error, etc.)
- Network errors or timeouts
- Invalid JSON in the response body
Security
- Never commit your API key. Use environment variables or a secrets manager.
- Never hardcode keys in example scripts. All examples use
TrustOSClient()with no inline key. - See SECURITY.md for the vulnerability disclosure policy.
Contributing
See CONTRIBUTING.md for guidelines.
Changelog
See CHANGELOG.md for version history.
License
MIT — see LICENSE.
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 trustos-0.1.0.tar.gz.
File metadata
- Download URL: trustos-0.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
386a85a7b67e7b5fa929399b91524c79b47e3742ce8312386619fa0e8fd35919
|
|
| MD5 |
e665514bcac787b2b39726be7ae5c9f4
|
|
| BLAKE2b-256 |
2b3fe4d343793a0ab226b2ea35814ebe95563c2039c2f2388e8ddb1fec17fc44
|
File details
Details for the file trustos-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trustos-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
625a6f9896aa12dcbb3834a4a172c698b6ce4110c3dc70cebfaa17908d0af0b9
|
|
| MD5 |
7d93581d4bf6201384bba81625239b2d
|
|
| BLAKE2b-256 |
c0dd1e3be3e0cdd076f95e38a4648731c742d2ed169f66ddd25625134f6aa400
|