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
Metadata
Release files for creed-sdk 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| creed_sdk-1.0.0.tar.gz | 12.9 kB | Without provenance | Details for creed_sdk-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| creed_sdk-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for creed_sdk-1.0.0-py3-none-any.whl |
Total release size: 22.3 kB
Release files / creed_sdk-1.0.0.tar.gz
| Download URL | creed_sdk-1.0.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d99acf0ac80102580d88e1ace65c987db5ee4dc0c53f83e8221324c2253fb2f6
|
|
BLAKE2b-256 checksum How to use checksums |
c220a5b7d61b48a8101b75c64a151918be9a0f80689c90315b37eddae9fa91e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / creed_sdk-1.0.0-py3-none-any.whl
| Download URL | creed_sdk-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad71308a6b829ac950f79b53212ee460fc53193600e029f3721df46c473c8c66
|
|
BLAKE2b-256 checksum How to use checksums |
47f029c0a0c0eb2e506683af9fd06e3353a1152d591d545f8a59114aec1291da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for creed-sdk 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.