Creed Space SDK - Governance infrastructure for AI agents
Project description
creed-sdk
Official Python SDK for Creed Space - governance infrastructure for AI agents.
Installation
pip install creed-sdk
# or
poetry add creed-sdk
# or
uv add creed-sdk
Quick Start
from creed_sdk import create_client
client = create_client(api_key="crd_live_...")
# Get a governance decision for a tool call
result = await client.decide(
tool_name="send_email",
arguments={
"to": "user@example.com",
"subject": "Hello",
},
on_allow=lambda d: print(f"Authorized: {d.decision_token}"),
on_deny=lambda d: print(f"Denied: {d.reasons}"),
)
# Don't forget to close the client
await client.close()
Context Manager (Recommended)
async with create_client(api_key="crd_live_...") as client:
result = await client.decide(
tool_name="send_email",
arguments={"to": "user@example.com"},
)
Features
- Governance Decisions - Get ALLOW/DENY decisions for tool calls
- Cryptographic Tokens - Signed JWT tokens for authorization proof
- Callback Flow Control -
on_allow,on_deny,on_require_humancallbacks - Audit Trail - Query tamper-evident hash-chain audit logs
- Async Native - Built on httpx for async/await support
- Type Hints - Full type annotations for IDE support
API Reference
create_client(api_key, base_url, timeout_ms)
Create a new Creed Space client.
client = create_client(
api_key="crd_live_...", # Required: Your API key
base_url="https://api.creed.space", # Optional: Custom API URL
timeout_ms=30000, # Optional: Request timeout (default: 30s)
)
client.decide(...)
Get a governance decision for a tool call.
result = await client.decide(
tool_name="send_email",
arguments={"to": "user@example.com"},
constitution_id="default", # Optional
context={ # Optional
"tenant_id": "...",
"user_id": "...",
},
on_allow=handle_allow, # Optional callback
on_deny=handle_deny, # Optional callback
on_require_human=handle_human, # Optional callback (planned feature)
)
# Async callbacks supported
async def handle_allow(decision):
await execute_tool(decision.decision_token)
client.authorize(...)
Verify a decision token before execution.
auth = await client.authorize(
decision_token=result.decision_token,
tool_name="send_email", # Optional: verify tool name matches
)
if auth.authorized:
print(f"Token valid until: {auth.claims.expires_at}")
client.audit(...)
Query the audit trail for a run.
audit = await client.audit(
run_id="run_123",
action_id=None, # Optional: specific action
limit=50,
)
print(f"Events: {audit.events}")
print(f"Integrity verified: {audit.integrity.verified}")
client.status()
Get service status and feature availability.
status = await client.status()
print(f"Service: {status.service}")
print(f"Features: {status.features}")
Utilities
compute_args_hash(args)
Compute SHA-256 hash of arguments for verification.
from creed_sdk import compute_args_hash
hash_value = compute_args_hash({"to": "user@example.com"})
# 'sha256:...'
is_token_expired(token)
Check if a decision token is expired.
from creed_sdk import is_token_expired
if is_token_expired(token):
# Request a new decision
pass
Error Handling
from creed_sdk import create_client
from creed_sdk.errors import (
CreedError,
AuthenticationError,
RateLimitError,
TimeoutError,
)
try:
result = await client.decide(...)
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except TimeoutError:
print("Request timed out")
except CreedError as e:
print(f"Error: {e.code} - {e.message}")
Decision Types
| Decision | Status | Description |
|---|---|---|
ALLOW |
Active | Tool execution authorized |
DENY |
Active | Tool execution blocked |
REQUIRE_HUMAN |
Planned | Human review required |
REQUIRE_STEPUP |
Planned | Step-up authentication required |
Type Definitions
from creed_sdk.types import (
AllowDecision,
DenyDecision,
RequireHumanDecision,
AuthorizeResult,
AuditResult,
StatusResult,
)
Requirements
- Python 3.10+
- httpx 0.25+
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Type check
mypy creed_sdk
# Lint
ruff check creed_sdk
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 creed_sdk-1.0.0.tar.gz.
File metadata
- Download URL: creed_sdk-1.0.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d99acf0ac80102580d88e1ace65c987db5ee4dc0c53f83e8221324c2253fb2f6
|
|
| MD5 |
82e80c23b55a90661e242fc6103cd88f
|
|
| BLAKE2b-256 |
c220a5b7d61b48a8101b75c64a151918be9a0f80689c90315b37eddae9fa91e2
|
File details
Details for the file creed_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: creed_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad71308a6b829ac950f79b53212ee460fc53193600e029f3721df46c473c8c66
|
|
| MD5 |
12a398c66e7798dbda828c0da2d93ca1
|
|
| BLAKE2b-256 |
47f029c0a0c0eb2e506683af9fd06e3353a1152d591d545f8a59114aec1291da
|