Framework-agnostic runtime boundary enforcement for AI systems
Project description
SafeAI
Your AI agents are powerful. Are they safe?
Why SafeAI · Quick Start · Features · Integrations · Docs
The Problem
AI agents are shipping to production with zero runtime security. They can leak API keys in prompts, expose customer PII in responses, call unauthorized tools, and execute dangerous commands — and nobody finds out until the incident report.
Model safety training alone doesn't prevent these failures. You need enforcement at runtime, at the boundaries where data actually moves.
The Solution
SafeAI is the runtime security layer that sits between your AI agents and the outside world. It intercepts every prompt, tool call, and model response — blocking secrets, redacting PII, enforcing policies, and logging everything to an immutable audit trail.
Two lines to get started. Zero changes to your existing code.
from safeai import SafeAI
ai = SafeAI.quickstart()
# Block secrets before they reach any LLM
scan = ai.scan_input("Summarize this: token=sk-ABCDEF1234567890ABCDEF")
# => BLOCKED — secret detected, never reaches the model
# Redact PII from model responses before your users see them
guard = ai.guard_output("Contact alice@example.com or call 555-123-4567")
print(guard.safe_output)
# => "Contact [REDACTED] or call [REDACTED]"
Works with OpenAI, Anthropic, Google, LangChain, CrewAI, AutoGen, Claude Code, Cursor, and any HTTP-based AI stack.
How It Works
SafeAI enforces security at three runtime boundaries — the exact points where incidents happen:
┌──────────────────────────────────┐
User / Agent ───▶ │ INPUT BOUNDARY (scan_input) │ ───▶ AI Provider
│ ACTION BOUNDARY (intercept) │ (OpenAI, Gemini,
AI Provider ◀─── │ OUTPUT BOUNDARY (guard_output) │ ◀─── Claude, etc.)
└──────────────────────────────────┘
SafeAI Runtime
| Boundary | What it stops |
|---|---|
| Input | Secrets, credentials, and sensitive data in prompts before they reach the model |
| Action | Unauthorized tool calls, dangerous commands (rm -rf /, DROP TABLE), and cross-agent messaging violations |
| Output | PII, internal data, and unsafe content in model responses before they reach users |
Every decision is logged. Every action is auditable. No exceptions.
Quick Start
Install
pip install safeai-sdk
With extras for your stack:
pip install "safeai-sdk[vault]" # HashiCorp Vault backend
pip install "safeai-sdk[aws]" # AWS Secrets Manager backend
pip install "safeai-sdk[mcp]" # MCP server for coding agents
pip install "safeai-sdk[all]" # Everything
Scaffold a full project
safeai init --path .
This generates safeai.yaml, policies, contracts, agent identities, plugins, and alert rules — ready for production. Then:
ai = SafeAI.from_config("safeai.yaml")
Deploy as a sidecar proxy
Protect any AI stack without changing a single line of application code:
safeai serve --mode sidecar --host 127.0.0.1 --port 8910 --config safeai.yaml
curl http://127.0.0.1:8910/v1/health # Health check
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"}'
AI-powered auto-configuration
Let SafeAI's intelligence layer analyze your codebase and generate tailored security policies:
safeai intelligence auto-config --apply
What SafeAI Does
🔒 Detection & Prevention
| Capability | Description |
|---|---|
| Secret Detection | Blocks API keys, tokens, and credentials before they reach any LLM |
| PII Protection | Auto-redacts emails, phone numbers, SSNs, credit cards, and more |
| Content Moderation | 80+ detectors for toxicity, prompt injection, jailbreaks — all local, no external APIs |
| Dangerous Commands | Stops rm -rf /, DROP TABLE, fork bombs, pipe-to-shell, force pushes |
🛡️ Policy & Control
| Capability | Description |
|---|---|
| Policy Engine | Priority-based YAML rules with tag hierarchies, hot reload, and boundary-specific matching |
| Tool Contracts | Declare what each tool can accept/emit — undeclared tools are denied by default |
| Agent Identity | Bind agents to specific tools and clearance levels for zero-trust enforcement |
| Approval Workflows | Human-in-the-loop gates for high-risk operations with TTL and dedup |
🏗️ Infrastructure
| Capability | Description |
|---|---|
| Encrypted Memory | Schema-enforced agent memory with field-level encryption and auto-expiry |
| Capability Tokens | Scoped, time-limited tokens for secret access — agents never see raw credentials |
| Audit Trail | Append-only logs with context hashes, filterable by agent, tool, session, and time |
| Multi-Provider Routing | Priority, cost, latency, and round-robin strategies with circuit-breaker failover |
🚀 Operations & Scale
| Capability | Description |
|---|---|
| Dashboard | Web UI for incidents, approvals, compliance summaries, and tenant/RBAC controls |
| Alerting | File, webhook, Slack, email, PagerDuty, and Opsgenie channels with Prometheus metrics |
| Skills System | Install pre-built packages — GDPR, HIPAA, PCI-DSS, prompt injection shield — in one command |
| Intelligence Layer | 5 AI advisory agents for auto-config, policy recs, incident explanation, and compliance mapping |
| Cost Governance | Track token usage, enforce budgets with hard blocks, extract costs from provider responses |
Works With Everything
| AI Providers | Agent Frameworks | Coding Agents | Deployment |
|---|---|---|---|
| OpenAI | LangChain | Claude Code | Python SDK |
| Anthropic Claude | CrewAI | Cursor | REST API (sidecar) |
| Google Gemini | AutoGen | Copilot | Gateway proxy |
| Ollama | Claude ADK | Any MCP client | MCP server |
| Any HTTP API | Google ADK | CLI hooks |
# Example: Wrap any LangChain tool in 3 lines
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")
CLI at a Glance
safeai init --path . # Scaffold config and policies
safeai serve --mode sidecar --port 8910 # Start the proxy server
safeai setup claude-code --config safeai.yaml # Install into Claude Code
safeai setup cursor --config safeai.yaml # Install into Cursor
safeai mcp --config safeai.yaml # Start MCP server
safeai intelligence auto-config --path . # AI-powered auto-configuration
safeai skills add prompt-injection-shield # Install a skill package
safeai scan --boundary input --input "text" # Scan from the command line
safeai approvals list --status pending # Manage approval queues
safeai observe agents # Agent observability
[!TIP] Run
safeai --helpor see the full CLI reference for all commands.
Extend with Plugins
Drop custom detectors, adapters, and policy templates into plugins/:
def safeai_detectors():
return [(r"my-pattern", "custom.tag", "my_detector")]
def safeai_policy_templates():
return [{"name": "my-template", "template": {"version": "v1alpha1", "policies": []}}]
Built-in template packs: finance, healthcare, support.
Documentation
| Resource | Link |
|---|---|
| Getting started | Installation · Quickstart · Configuration |
| Guides | Policy Engine · Tool Contracts · Agent Identity · Audit Logging |
| Integrations | LangChain · CrewAI · AutoGen · Coding Agents |
| Reference | CLI · API · Architecture |
Local Development
git clone https://github.com/enendufrankc/safeai.git
cd safeai
pip install -e ".[dev,all]"
Run the quality gates:
ruff check safeai tests # Lint
mypy safeai # Type check
python -m pytest tests/ -v # Test
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.9.1.tar.gz.
File metadata
- Download URL: safeai_sdk-0.9.1.tar.gz
- Upload date:
- Size: 187.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9012af4dd3cb8a23761ec7860c9399854d3b4c812d7d85894ffd0f273f6950ec
|
|
| MD5 |
0e0155108a700bb0de570356d0e9a809
|
|
| BLAKE2b-256 |
da731025f8868d56e4fad8dda11d511cd1648497d33e86c41ba38a88e0131134
|
File details
Details for the file safeai_sdk-0.9.1-py3-none-any.whl.
File metadata
- Download URL: safeai_sdk-0.9.1-py3-none-any.whl
- Upload date:
- Size: 199.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26f64df987d68e07926186d55043ff396889038d7d4d7a712d07cf8416a09dc2
|
|
| MD5 |
af8ca699df396c4b73409e3eeaa07cfc
|
|
| BLAKE2b-256 |
22b97595db5f259c7679772ddd9ea1587beb99c8f1e1207f3c7945449890ea5f
|