Python SDK
The official SupraWall Python library for securing AI agents. Implement Enterprise-grade guardrails, vault injection, and live monitoring with a single line of code.
Installation
pip install suprawallQuickstart
The simplest way to use SupraWall is via the SupraWall convenience class. It automatically handles authentication and middleware configuration.
from suprawall import SupraWall
# 1. Initialize with your API Key
supra = SupraWall("ag_your_api_key")
# 2. Protect any agent or function
agent = supra.protect(my_agent)
# 3. Running the agent automatically triggers policy evaluation
response = agent.invoke("Transfer $500 to my savings account")Framework Integrations
LangChain
SupraWall wraps any Runnable and injects security checks into the executive loop.
from langchain_openai import ChatOpenAI
from suprawall import SupraWall
supra = SupraWall("ag_...")
llm = ChatOpenAI(model="gpt-4o")
# Wrap the chain
chain = supra.protect(llm | my_prompt | my_tools)
chain.invoke("Delete all files") # Blocked by SupraWall locally or in cloudCrewAI
Protect entire Crews or individual Agents to ensure task completion follows your organizational policies.
from crewai import Agent, Crew
from suprawall import SupraWall
supra = SupraWall("ag_...")
# Secure the entire crew
crew = supra.protect(Crew(
agents=[researcher, writer],
tasks=[task1, task2]
))
crew.kickoff()Runtime Enforcement
Define deterministic policies for token_limits, budget_caps, and pii_scrubbing.
Token & Budget Limits
# Set per-call and monthly token limits for LLM agents
supra.enforce("token_limit", {
max_tokens: 4000,
monthly_budget_usd: 50.0
})
# Automatic circuit breaker for infinite loops
supra.enforce("loop_detection", { threshold: 5, action: "BLOCK" })PII Scrubbing & Redaction
# Redact sensitive data from outbound tool calls
supra.redact("email", "phone", "ssn")
# Use custom regex for proprietary secret patterns
supra.redact(pattern=r"sk-prod-[a-zA-Z0-9]{32}")Vault & Zero-Trust
Suprawall Python SDK's vault injection prevents secret exfiltration from LLM context windows. Tokens like $SUPRAWALL_VAULT_... are resolved just-in-time.
from suprawall import SupraWall
supra = SupraWall("ag_...")
# Resolve secrets at the edge for zero-knowledge tool execution
result = supra.protect(my_tool).run({
"api_key": "$SUPRAWALL_VAULT_SENDGRID_KEY",
"recipient": "user@example.com"
})Advanced Options
from suprawall import SupraWall, SupraWallOptions
options = SupraWallOptions(
api_key="ag_...",
environment="production",
timeout=5.0, # Fail-fast for low latency
fail_open=False # Strict security: block if SupraWall Cloud is unreachable
)
supra = SupraWall(options=options)Need help with Python?
Our team of security engineers is available for implementation reviews.