Secure your LLM tools with enterprise-grade authorization. One decorator, instant security. Zero infrastructure.
pip install d2-sdk
# Generate local policy
python -m d2 init
# In your app startup
await configure_rbac()
@d2_guard("weather_api")
def get_weather(location: str):
return weather_service.fetch(location)
# Set user context
set_user("alice", roles=["developer"])
From local development to enterprise scale, D2 provides the security and performance your AI agents need.
Secure by default. Undecorated functions are automatically blocked. No accidental security holes.
Change permissions in our dashboard. They're enforced globally within 5 seconds. No cache invalidation.
Just add @d2_guard to your functions. That's it. No complex integration or infrastructure changes.
Start with local file-based policies for development. Scale to cloud for production with zero code changes.
Built-in CLI for policy management, diagnostics, and inspection. Perfect developer experience.
ASGI middleware for FastAPI/Starlette or manual context setting. Works with any Python framework.
Replace hundreds of lines of authorization logic with a single decorator.
# Hundreds of lines of auth logic
def check_permissions(user, tool, action):
# Database queries
# Cache lookups
# Role validation
# Permission checks
# Error handling
# Logging
# ...and more
@app.route('/weather')
def get_weather():
if not check_permissions(
user, 'weather', 'read'
):
return 403
# Your actual logic here
return weather_service.fetch(location)
# One-time setup
await configure_rbac()
# Set user context (once per request)
set_user("alice", roles=["developer"])
# Protect your tools
@d2_guard("weather_api")
def get_weather(location: str):
return weather_service.fetch(location)
# That's it. Seriously.
Start free with local mode. Scale to cloud for production with enterprise features.
For growing teams
For large organizations
All cloud plans include:
Join hundreds of developers using D2 to secure their AI applications. Start with local mode, scale to cloud.
No spam. Unsubscribe anytime. We'll only email about product updates.