Observed since 21 Oct, 09:31 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Official Python SDK for AgentGuard — the AI action firewall
Official Python SDK for AgentGuard — the AI action firewall that keeps your agents safe.
pip install agentguard
Requirements: Python 3.8 or later.
from agentguard import AgentGuard
guard = AgentGuard(api_key="ag_live_YOUR_KEY_HERE")
Then, before your agent executes any action:
result = guard.check(
action="send_email",
payload={"to": "user@example.com", "body": "Hello!"},
)
if result.decision == "block":
raise Exception(f"Action blocked: {result.reason}")
# proceed with the action
AgentGuard(
api_key: str, # required — from your AgentGuard dashboard
base_url: str = None, # default: https://agentguard.dev/api
# also read from AGENTGUARD_BASE_URL env var
timeout: float = 5.0, # request timeout in seconds
)
The base_url is resolved in this order:
base_url argument passed to the constructorAGENTGUARD_BASE_URL environment variablehttps://agentguard.dev/api (production default)guard.check() Referenceresult = guard.check(
action: str, # required — name of the action
payload: dict, # required — data the agent is acting on
agent_id: str | None = None, # which agent is acting (improves logging)
app_user_id: str | None = None, # end user ID (enables cross-user detection)
app_name: str | None = None, # identifies your app in the dashboard
risk_context: dict | None = None, # extra metadata for risk scoring
)
CheckResult@dataclass
class CheckResult:
decision: Literal["allow", "block", "review"]
risk_level: Literal["low", "medium", "high", "critical"]
reason: str
log_id: int | None
prompt_injection_detected: bool
result = guard.check(action=action, payload=payload)
if result.decision == "allow":
# Safe to proceed. Execute the action.
execute_action(action, payload)
elif result.decision == "review":
# High-risk but not definitively malicious.
# Queue for human review or notify your security team.
queue_for_review(action, payload, result.reason)
elif result.decision == "block":
# Policy violation or detected threat. Do NOT proceed.
raise Exception(f"Blocked ({result.risk_level}): {result.reason}")
from agentguard import (
AgentGuard,
AgentGuardAuthError,
AgentGuardNetworkError,
AgentGuardServerError,
)
try:
result = guard.check(action=action, payload=payload)
except AgentGuardAuthError as e:
# Invalid or expired API key — check your dashboard
print(f"Auth error: {e}")
except AgentGuardNetworkError as e:
# Connectivity issue — the SDK already retried once
# Fall back gracefully (allow or queue for later)
print(f"Network error: {e}")
except AgentGuardServerError as e:
# Unexpected server error (5xx)
print(f"Server error {e.status_code}: {e}")
The SDK automatically retries once on network errors. Auth errors and server errors are never retried.
from flask import Flask, request, jsonify
from agentguard import AgentGuard
import os
guard = AgentGuard(api_key=os.environ["AGENTGUARD_KEY"])
app = Flask(__name__)
@app.post("/agent/send-email")
def send_email():
data = request.get_json()
result = guard.check(
action="send_email",
payload={"to": data["to"], "body": data["body"]},
app_user_id=data.get("userId"),
agent_id=data.get("agentId"),
)
if result.decision == "block":
return jsonify({"error": result.reason}), 403
# send the email...
return jsonify({"ok": True})
When you're ready to publish:
cd sdks/python
pip install build twine
python -m build
twine upload dist/*
Make sure your pyproject.toml has the correct name, version, and license fields before publishing.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 2 May 2026 | 1 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 21 Oct, 09:31 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:cf8ad1451ec520b688d37ac5d30aca117f27f370dc83857b335026c45b4a718b