Python SDK for Chox - AI governance proxy
Project description
chox-sdk
Python SDK for Chox — AI governance proxy. Evaluate AI tool calls before execution to prevent unintended financial operations, data deletions, and other risky actions.
Why Chox?
As AI agents gain access to external APIs (Stripe, Slack, SQL), they need governance. Chox sits between your agent and those APIs to:
- Evaluate every tool call (financial operations, data deletions, message sends, etc.)
- Classify the action type and risk level
- Return a verdict — allow, block, escalate, or warn — before the agent proceeds
- Log all activity for audit trails
This SDK wraps the POST /api/v1/evaluate endpoint with a clean API, automatic retry on network failures (fail-open), and precise type hints.
Install
pip install chox-sdk
Quickstart
from chox import ChoxClient
chox = ChoxClient(
base_url="https://chox.example.com",
token="chox_token_...",
)
# Evaluate before a risky operation
verdict = chox.evaluate(
tool="stripe.create_charge",
arguments={"amount": 5000, "currency": "USD"},
context={"user_id": "user_123"},
)
if verdict.verdict == "allow":
# Safe to proceed
stripe.Charge.create(amount=5000, currency="USD")
elif verdict.verdict == "block":
raise ValueError(f"Action blocked: {verdict.reason}")
elif verdict.verdict == "escalate":
# Requires human approval
send_to_approval_queue(verdict.reason)
Configuration
chox = ChoxClient(
base_url="https://chox.example.com", # Required: Your Chox gateway URL
token="chox_token_...", # Required: Caller token or admin key
fail_open=True, # Optional: Default True. If Chox is unreachable, return allow verdict
timeout=5.0, # Optional: Default 5.0 seconds. Request timeout
)
Authentication
- Caller token (
chox_token_...): Use this in production. Tied to a specific AI system in Chox, can only evaluate with that token. - Admin key (
chox_admin_...): Use this for setup/testing. Can manage projects, integrations, and callers, but not recommended for ongoing agent evaluation.
Verdicts
The evaluate() method returns an EvaluateResponse dataclass with these fields:
from chox import EvaluateResponse
verdict: EvaluateResponse = chox.evaluate(...)
# Fields:
verdict.request_id # Unique request ID for audit logging
verdict.verdict # "allow" | "block" | "escalate" | "warn"
verdict.action_type # "read" | "write" | "delete" | "financial" | "unknown"
verdict.risk_score # 0 (safe) to 1 (critical)
verdict.reason # Human-readable explanation
verdict.evaluated_at # ISO 8601 timestamp
Verdict meanings:
allow— Safe to proceedblock— Blocked by policy; do not proceedescalate— Requires human approval (e.g., large transfer)warn— Proceed with caution; log prominently
Error Handling
from chox import ChoxClient, ChoxError, ChoxNetworkError
chox = ChoxClient(base_url="...", token="...")
try:
verdict = chox.evaluate(tool="stripe.create_charge")
except ChoxError as e:
# API returned non-2xx status
print(f"Chox API error {e.status}: {e.body}")
except ChoxNetworkError as e:
# Network timeout or unreachable
print(f"Network error: {e}")
if e.cause:
print(f"Caused by: {e.cause}")
Note: If fail_open=True (default), network errors and timeouts return an allow verdict instead of raising, so your agent never gets blocked by Chox being temporarily down.
API Reference
Evaluate
verdict = chox.evaluate(
tool: str, # Dot-notation tool name, e.g., "stripe.create_charge"
arguments: dict[str, Any] | None = None, # Tool arguments as JSON
caller_token: str | None = None, # Optional override caller token
context: dict[str, Any] | None = None, # Optional context (user_id, session, etc.)
)
Projects
chox.projects.create(name=..., slug=...) # Create a project; returns raw admin key once
chox.projects.get() # Get authenticated project
Callers (AI Systems)
chox.callers.create(name=..., description="") # Register an AI system; returns raw token once
chox.callers.list() # List all callers
chox.callers.delete(id) # Remove a caller
Integrations
chox.integrations.create( # Register an external API
name="stripe",
integration_type="http", # "http" or "mcp"
destination_url="https://api.stripe.com",
)
chox.integrations.list() # List all integrations
chox.integrations.delete(id) # Remove an integration
Logs
chox.logs.list( # Query evaluation logs
caller_id=None,
integration=None,
action_type=None,
start=None, # ISO 8601 timestamp
end=None, # ISO 8601 timestamp
limit=None,
offset=None,
)
chox.logs.get(id) # Get a specific log entry
Stats
chox.stats.actions(start=None, end=None) # Breakdown by action type
chox.stats.hourly(start=None, end=None) # Hourly activity counts
chox.stats.integrations(start=None, end=None) # Per-integration traffic
chox.stats.total() # Total request count
Type Hints
This SDK is fully typed for use with mypy, pyright, and other type checkers.
from chox import ChoxClient, EvaluateResponse
chox: ChoxClient = ChoxClient(base_url="...", token="...")
verdict: EvaluateResponse = chox.evaluate(tool="stripe.create_charge")
# Type checker catches mismatches:
if verdict.verdict == "invalid": # ✗ mypy: Type '"invalid"' is not assignable to '"allow" | "block" | "escalate" | "warn"'
pass
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 chox_ai_sdk-0.1.0.tar.gz.
File metadata
- Download URL: chox_ai_sdk-0.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16c5948fe4d7d51c9d8df306c15eb86340ba57832d4809aed483d45772ef9988
|
|
| MD5 |
277066114308ca8d9f323d0f160b2ea3
|
|
| BLAKE2b-256 |
9fa12abd4c9cd93fde24a8b66af2cdd63cfd9cfaa1cfe3f390bf07e6154ab210
|
File details
Details for the file chox_ai_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chox_ai_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e87b4f4cfdf1b20982dfd5b7184b37c9220bc5303710ee32a3a4c83638c6041
|
|
| MD5 |
5c0eb91d12560045cfec2180efaa9d89
|
|
| BLAKE2b-256 |
7e140da6869bab3d4ebfe2251918625c290271ea76a737f47d6e2c5ddd523070
|