Framework-agnostic runtime boundary enforcement for AI systems
Project description
SECURE. INTELLIGENT. TRUSTED.
The runtime security layer for AI agents.
Block secrets. Redact PII. Enforce policies. Control tool calls. Require approvals.
Works with any model stack, framework, and deployment style.
Table of Contents
- What SafeAI Is
- Capability Overview
- Install
- Quick Start (SDK)
- Scaffold a Full Config Project
- Run as a Proxy API
- CLI Commands
- Framework and Agent Integrations
- Plugins and Policy Templates
- Dashboard and Enterprise Operations
- Documentation Map
- Contributing, Security, and Governance
- Local Development
- License
What SafeAI Is
SafeAI enforces policy at three runtime boundaries:
input: before user or agent data reaches a model.action: before and after tool execution, and during agent-to-agent messaging.output: before model output is returned or forwarded.
That model keeps policy decisions close to execution, where incidents actually happen.
+----------------------------------+
User / Agent ---> | INPUT BOUNDARY (scan_input) | ---> AI Provider
| ACTION BOUNDARY (intercept) | (OpenAI, Gemini,
AI Provider <--- | OUTPUT BOUNDARY (guard_output)| <--- Claude, etc.)
+----------------------------------+
SafeAI Runtime
Current status: Sprint 0 through Phase 7 complete, with v0.7.0 release gate passed.
Capability Overview
SafeAI is intentionally broad. This is the complete capability set currently implemented:
| Area | Capabilities |
|---|---|
| Detection and classification | Built-in detectors for secrets and personal data (email, phone, ssn, credit_card, api_key) with hierarchical tags |
| Policy engine | Priority-based first-match rules, YAML policies, schema validation, hot reload, fallback output templates |
| Input and output controls | Prompt scanning (scan_input), response guarding (guard_output), redaction/block/allow enforcement |
| Structured and file scanning | Nested payload scanning (scan_structured_input) and file scanning (scan_file_input) for JSON and text |
| Tool boundary enforcement | Request contract checks, response filtering, undeclared tool denial, per-field stripping |
| Agent identity | Agent registry, tool binding, clearance-tag enforcement |
| Agent messaging | Source/destination-aware, policy-gated agent-to-agent message interception |
| Approvals | require_approval runtime gate with persistent queue and explicit approve/deny flow |
| Secrets access | Capability-token TTL/scope/session binding, secret manager abstraction, Env/Vault/AWS backends |
| Memory security | Schema-enforced memory controller, encrypted handle storage, retention and purge workflow |
| Auditability | Append-only JSON logs, rich query filters (boundary/action/agent/tool/tag/session/time/metadata), context hashes and event IDs |
| Proxy runtime | Sidecar and gateway modes, upstream forwarding, health endpoint, policy reload endpoint |
| Observability | Prometheus-style metrics (/v1/metrics) with request/decision counters and latency buckets |
| Integrations | LangChain, CrewAI, AutoGen, Claude ADK, Google ADK, coding-agent hooks, MCP server |
| Extensibility | Plugin loader for detectors/adapters/templates, built-in policy template catalog (finance, healthcare, support) |
| Operations UI | Web dashboard (/dashboard) for incidents, approvals, compliance summaries, tenant/RBAC controls, alerts |
| Intelligence layer | 5 AI advisory agents: auto-config, policy recommender, incident explainer, compliance mapper, integration generator. BYOM (Bring Your Own Model), metadata-only, human-approved staging |
Install
uv pip install safeai-sdk
Or with pip:
pip install safeai-sdk
Optional extras:
uv pip install "safeai-sdk[vault]" # HashiCorp Vault backend
uv pip install "safeai-sdk[aws]" # AWS Secrets Manager backend
uv pip install "safeai-sdk[mcp]" # MCP server support
uv pip install "safeai-sdk[all]" # Vault + AWS + MCP
uv pip install "safeai-sdk[dev]" # local development tooling
Quick Start (SDK)
For fast adoption with no config files:
from safeai import SafeAI
ai = SafeAI.quickstart()
Then enforce both ends of the model call:
# Input boundary
scan = ai.scan_input("Summarize this: token=sk-ABCDEF1234567890ABCDEF")
print(scan.decision.action, scan.decision.reason)
# Output boundary
guard = ai.guard_output("Contact alice@example.com")
print(guard.safe_output)
Structured payload example:
payload = {"user": {"email": "alice@example.com"}, "note": "hello world"}
result = ai.scan_structured_input(payload, agent_id="default-agent")
print(result.decision.action)
print(result.filtered)
Scaffold a Full Config Project
When you need full policy and runtime control:
safeai init --path .
This scaffolds:
safeai.yamlpolicies/default.yamlcontracts/example.yamlschemas/memory.yamlagents/default.yamlplugins/example.pytenants/policy-sets.yamlalerts/default.yaml
Use config mode via:
from safeai import SafeAI
ai = SafeAI.from_config("safeai.yaml")
Run as a Proxy API
Start the proxy:
safeai serve --mode sidecar --host 127.0.0.1 --port 8910 --config safeai.yaml
Health check:
curl http://127.0.0.1:8910/v1/health
Hello world scan:
curl -s -X POST http://127.0.0.1:8910/v1/scan/input \
-H "content-type: application/json" \
-d '{"text":"hello world","agent_id":"default-agent"}'
Core HTTP endpoints:
GET /v1/healthGET /v1/metricsPOST /v1/scan/inputPOST /v1/scan/structuredPOST /v1/scan/filePOST /v1/guard/outputPOST /v1/intercept/toolPOST /v1/intercept/agent-messagePOST /v1/memory/writePOST /v1/memory/readPOST /v1/memory/resolve-handlePOST /v1/memory/purge-expiredPOST /v1/audit/queryPOST /v1/policies/reloadGET /v1/pluginsGET /v1/policies/templatesGET /v1/policies/templates/{template_name}POST /v1/proxy/forwardGET /v1/intelligence/statusPOST /v1/intelligence/explainPOST /v1/intelligence/recommendPOST /v1/intelligence/complianceGET /dashboard
CLI Commands
Daily commands you will actually use:
safeai init --path .
safeai validate --config safeai.yaml
safeai scan --boundary input --input "hello world"
safeai logs --tail 20 --json-output
safeai serve --mode sidecar --port 8910
safeai approvals list --status pending
safeai approvals approve <request_id> --approver security-lead
safeai approvals deny <request_id> --approver security-lead --note "policy mismatch"
safeai templates list
safeai templates show --name healthcare --format yaml
safeai setup claude-code --config safeai.yaml --path .
safeai setup cursor --config safeai.yaml --path .
safeai setup generic --config safeai.yaml
safeai hook --config safeai.yaml
safeai mcp --config safeai.yaml
safeai intelligence auto-config --path . --output-dir .safeai-generated
safeai intelligence recommend --since 7d
safeai intelligence explain <event_id>
safeai intelligence compliance --framework hipaa
safeai intelligence integrate --target langchain --path .
Framework and Agent Integrations
Built-in adapters:
- LangChain
- CrewAI
- AutoGen
- Claude ADK
- Google ADK
Coding-agent integration:
- universal hook adapter (
safeai hook) - installer commands for Claude Code and Cursor (
safeai setup ...) - MCP server (
safeai mcp) for MCP-compatible clients
Quick adapter example:
from safeai import SafeAI
from safeai.middleware.langchain import wrap_langchain_tool
ai = SafeAI.from_config("safeai.yaml")
safe_tool = wrap_langchain_tool(ai, my_tool, agent_id="default-agent")
Plugins and Policy Templates
Phase 6 added extensibility as first-class behavior.
Plugin model:
- load plugin modules from
plugins/*.py(configurable insafeai.yaml) - extend detector patterns
- register adapters
- contribute policy templates
Template catalog:
- built-in packs:
finance,healthcare,support - list with
safeai templates list - inspect with
safeai templates show --name <template> - proxy discovery endpoints via
/v1/policies/templates*
Minimal plugin shape:
def safeai_detectors():
return [
(r"my-custom-pattern", "custom.tag", "custom_detector"),
]
def safeai_adapters():
return {
"my-adapter": lambda safeai: object(),
}
def safeai_policy_templates():
return [
{
"name": "my-template",
"template": {"version": "v1alpha1", "policies": []},
}
]
Dashboard and Enterprise Operations
SafeAI includes a dashboard surface for security operations:
- incidents and policy events
- approval queue workflow
- compliance report summaries
- tenant-scoped policy sets
- RBAC checks
- alert rule evaluation and alert logs
Run the proxy and open /dashboard in your browser.
Documentation Map
Start here:
- Docs home:
docs/index.md - Install:
docs/getting-started/installation.md - Quickstart:
docs/getting-started/quickstart.md - Configuration:
docs/getting-started/configuration.md
Guides:
- Policy engine:
docs/guides/policy-engine.md - Tool contracts:
docs/guides/tool-contracts.md - Agent identity:
docs/guides/agent-identity.md - Structured scanning:
docs/guides/structured-scanning.md - Capability tokens:
docs/guides/capability-tokens.md - Audit logging:
docs/guides/audit-logging.md
Integrations:
- Integrations overview:
docs/integrations/index.md - LangChain:
docs/integrations/langchain.md - CrewAI:
docs/integrations/crewai.md - AutoGen:
docs/integrations/autogen.md - Claude ADK:
docs/integrations/claude-adk.md - Google ADK:
docs/integrations/google-adk.md - Coding agents:
docs/integrations/coding-agents.md - Proxy/sidecar:
docs/integrations/proxy-sidecar.md - Plugins:
docs/integrations/plugins.md
Reference:
- CLI reference:
docs/cli/index.md - API reference:
docs/reference/safeai.md - Changelog:
docs/changelog.md
Project and planning:
- Architecture:
docs/project/architecture.md - Roadmap:
docs/project/roadmap.md - Security:
docs/project/security.md - Governance:
docs/project/governance.md - Compatibility:
docs/project/compatibility.md - Intelligence layer:
docs/guides/intelligence.md - Delivery tracker:
docs/brainstom/15-delivery-tracker.md
Notebooks:
- Notebook index:
docs/notebooks/index.md - Raw notebooks:
notebook/
Contributing, Security, and Governance
Core project policies:
- Contributing guide:
CONTRIBUTING.md - Security policy:
SECURITY.md - Governance model:
GOVERNANCE.md - Maintainer policy:
MAINTAINERS.md - Code of conduct:
CODE_OF_CONDUCT.md - Compatibility and semver contract:
COMPATIBILITY.md
Local Development
git clone https://github.com/enendufrankc/safeai.git
cd safeai
uv sync --extra dev --extra all
Or with pip:
pip install -e ".[dev,all]"
Quality gates used in CI:
uv run ruff check safeai tests
uv run mypy safeai
uv run python -m pytest tests/ -v
License
SafeAI is licensed under Apache 2.0.
Project details
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 safeai_sdk-0.8.1.tar.gz.
File metadata
- Download URL: safeai_sdk-0.8.1.tar.gz
- Upload date:
- Size: 147.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ede061fe3a696896092e703602054c8bc06d62fc4efae52f631c79b9f3a54092
|
|
| MD5 |
7bbee9447aaa94fb6d726e775ab5c0d9
|
|
| BLAKE2b-256 |
f1cd495385f1ea69f0f2a6129b6253861e4de63411889a7efafe9289c2e619ff
|
Provenance
The following attestation bundles were made for safeai_sdk-0.8.1.tar.gz:
Publisher:
publish.yml on enendufrankc/safeai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeai_sdk-0.8.1.tar.gz -
Subject digest:
ede061fe3a696896092e703602054c8bc06d62fc4efae52f631c79b9f3a54092 - Sigstore transparency entry: 976314259
- Sigstore integration time:
-
Permalink:
enendufrankc/safeai@71b593c80c20a2e9672ca9f2920659c86878cbbd -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/enendufrankc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@71b593c80c20a2e9672ca9f2920659c86878cbbd -
Trigger Event:
release
-
Statement type:
File details
Details for the file safeai_sdk-0.8.1-py3-none-any.whl.
File metadata
- Download URL: safeai_sdk-0.8.1-py3-none-any.whl
- Upload date:
- Size: 142.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1adec9a9385766f3dc2cb0ba38055c908d980523670ac83410a02b3a7218b76e
|
|
| MD5 |
086b58d6cf500e67a2c52467b6767eaf
|
|
| BLAKE2b-256 |
07bcbdc2d434074bfd5ed1fa83cba4967d90d78e4bb2629c2c8ace374a30429b
|
Provenance
The following attestation bundles were made for safeai_sdk-0.8.1-py3-none-any.whl:
Publisher:
publish.yml on enendufrankc/safeai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
safeai_sdk-0.8.1-py3-none-any.whl -
Subject digest:
1adec9a9385766f3dc2cb0ba38055c908d980523670ac83410a02b3a7218b76e - Sigstore transparency entry: 976314261
- Sigstore integration time:
-
Permalink:
enendufrankc/safeai@71b593c80c20a2e9672ca9f2920659c86878cbbd -
Branch / Tag:
refs/tags/v0.8.1 - Owner: https://github.com/enendufrankc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@71b593c80c20a2e9672ca9f2920659c86878cbbd -
Trigger Event:
release
-
Statement type: