Current collected state Current
Observed since 20 Oct, 22:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Python SDK for AgentGuard Pro - AI governance and compliance platform
The official Python SDK for AgentGuard Pro - Enterprise AI governance and compliance platform.
Transform your AI infrastructure with a single line of code:
from agentguard import AgentGuard
# Initialize once
agentguard = AgentGuard(tenant_id="your-tenant")
# Before: Complex manual compliance
response = openai.ChatCompletion.create(model="gpt-4", messages=[...])
# After: Automatic compliance with intercept()
response = agentguard.intercept(
openai.ChatCompletion.create,
model="gpt-4",
messages=[...]
)
That's it! The intercept() method automatically handles:
pip install agentguard
export AGENTGUARD_API_KEY="your-api-key"
export AGENTGUARD_TENANT_ID="your-tenant-id"
from agentguard import AgentGuard
import openai
# Initialize AgentGuard
agentguard = AgentGuard()
# Intercept any AI call
response = agentguard.intercept(
openai.ChatCompletion.create,
model="gpt-4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
The SDK automatically detects and supports:
# Register your custom AI provider
agentguard.register_provider(
name='custom-llm',
detect_fn=lambda fn, args, kwargs: 'custom' in str(fn),
extract_model_fn=lambda fn, args, kwargs: kwargs.get('model', 'custom'),
extract_context_fn=lambda fn, args, kwargs: {'custom': True},
resource='ai:custom'
)
# Now intercept() works with your custom provider!
response = agentguard.intercept(custom_llm.generate, prompt="Hello")
from agentguard import AgentGuardError
try:
response = agentguard.intercept(
openai.ChatCompletion.create,
model="gpt-4",
messages=[{"role": "user", "content": "Sensitive request"}]
)
except AgentGuardError as e:
if e.code == 'AGENTGUARD_ACCESS_DENIED':
print(f"Access denied: {e}")
# Handle authorization failure
# For fine-grained control, use authorize() directly
auth_result = agentguard.authorize(
subject="user@example.com",
resource="ai:gpt-4",
action="generate",
context={"purpose": "customer_support"}
)
if auth_result['allowed']:
# Proceed with AI call
pass
The SDK still supports the legacy context manager pattern:
from agentguard import protect
with protect(context={"user_id": "123"}) as guard:
response = openai.ChatCompletion.create(...)
guard.complete(response)
AGENTGUARD_API_KEY: Your API key (required)AGENTGUARD_TENANT_ID: Default tenant IDAGENTGUARD_PRINCIPAL: Default principal/userAGENTGUARD_BASE_URL: API base URL (defaults to https://api.agentguard.pro)agentguard = AgentGuard(
api_key="your-api-key", # Or use env var
tenant_id="your-tenant", # Or use env var
principal="user@example.com", # Or use env var
base_url="https://custom.api" # Or use env var
)
See the examples/ directory for complete examples:
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.4 | 12 Jun 2025 | 7 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:06 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:74d9cd34af3a72ed8f7355ad5866284bcba4ef08e435b00bfad2d04f46f5b385