Python SDK
Protect an agent in a few lines.
Install the dependency-free client, point it at your deployment, and scan untrusted content before it enters model context.
Install the SDKConnect OpenRouter
Server configurationexport PROVIDER_MODE=openrouter
export OPENROUTER_API_KEY=sk-or-v1-...
export OPENROUTER_MODEL=openai/gpt-5.6
pnpm devKeep the OpenRouter key on the AgentGuard server. Deployed instances can alternatively save an encrypted workspace key under Console → Providers.
Install and scan
Python 3.10+pip install ./sdk/python
from agentguard import AgentGuard
guard = AgentGuard(base_url="http://localhost:3000")
result = guard.scan(
"Untrusted page content",
source="WEB_PAGE",
)
print(result["blocked"], result["risk"])Protect any agent framework
Sync and async middlewarefrom agentguard import AgentGuardMiddleware
guard = AgentGuardMiddleware()
# Gate prompts and retrieved context before the model.
guard.before_model(content, source="DOCUMENT")
# Gate arguments before execution and output before reuse.
@guard.wrap_tool
def browse(url: str) -> str:
return browser.fetch(url)Protect an OpenClaw workflow
Prompt · tool-call · tool-result gatescd plugins/openclaw
pnpm install --frozen-lockfile
pnpm build && pnpm pack
openclaw plugins install \
npm-pack:./agentguard-openclaw-0.1.0.tgz --force
openclaw plugins enable agentguard
openclaw config set \
plugins.entries.agentguard.hooks.allowConversationAccess true
openclaw gateway restartGuard tool calls
POST /api/v1/check-actionresult = guard.check_action(
tool_call={"name": "send_email", "arguments": {"to": "user@example.com"}},
reasoning_trace=["The page asked me to send it."],
trusted_context=["The user only requested a summary."],
)
if not result["allowed"]:
raise RuntimeError(result["reason"])Or use HTTP directly
POST /api/v1/scancurl -X POST "http://localhost:3000/api/v1/scan" \
-H "Content-Type: application/json" \
-d '{"text":"Untrusted page content","source":"WEB_PAGE"}'Authentication
Public scans and action checks do not require a key in the MVP. Set AGENTGUARD_API_KEY for uploads, batch scans, and job results. Set AGENTGUARD_BASE_URL to your hosted deployment; the SDK defaults to http://localhost:3000.
Risk model
Heuristic
35%
LLM judge
40%
Activation probe
25%
The active workspace policy controls the block threshold. All configured detectors must return valid responses; otherwise scans fail closed.