D2 Overview
D2 is a production-ready Python SDK that makes securing AI agents and LLM-powered tools straightforward and efficient. It replaces hundreds of lines of complex authorization logic with a single, powerful decorator. This allows developers to implement Role-Based Access Control (RBAC) at the code level, ensuring that functions are denied by default until explicitly authorized. D2 is designed for high-performance systems, offering both local file-based policies for development and a scalable cloud solution for production environments with minimal overhead.
How to use D2
Getting started with D2 is designed to be quick and simple, taking just a few minutes. First, install the SDK using pip: pip install d2-sdk. Next, protect your sensitive functions by adding the @d2.d2_guard("your_tool_name") decorator above them. After decorating your functions, run python -m d2 init in your terminal to automatically scan your code and generate a policy template. Finally, initialize D2 in your application's startup script and set the user context for each request, preferably using the with d2.set_user_context() manager to ensure proper handling.
Core Features of D2
- One Decorator Security: Secure any function by simply adding the
@d2_guarddecorator, instantly replacing complex auth logic. - Code-Level Security: Identifies and enforces authorization at the function level, not just API endpoints, with a deny-by-default security posture.
- Fast Policy Updates: Policy changes propagate across all environments in under a minute (as fast as 30 seconds on the Pro plan).
- Local & Cloud Modes: Start with simple local file-based policies for development and seamlessly scale to the cloud for production without code changes.
- Rich CLI Tools: A comprehensive command-line interface for policy management, inspection, and diagnostics to enhance the developer experience.
- Runtime Optimized: Built for high-performance production systems with intelligent caching and minimal overhead.
Use Cases for D2
D2 is ideal for developers building applications with AI agents or Large Language Models (LLMs) that interact with various tools and data sources. It can be used to secure access to internal APIs (e.g., a weather API), control actions that have external effects (e.g., sending emails or notifications), protect sensitive data operations (e.g., querying a user database), and manage permissions for file operations or interactions with third-party services.
Advantages of D2
The primary advantage of D2 is its simplicity and power. It dramatically reduces the amount of boilerplate code required for authorization, improving developer productivity and reducing the surface area for security bugs. Its runtime-optimized design ensures high performance, while the dual local/cloud modes provide a flexible workflow from development to production. The fast policy propagation allows for near-real-time permission changes, enhancing security and operational agility.
Pricing and Plans
D2 offers a freemium model with plans to suit different scales:
- Free Plan ($0): Perfect for development, includes 3 tools per app, 1 published app, 15-minute policy refresh, and 1 team member.
- Essentials Plan ($99/month): Designed for small teams, offers 10 tools per app, 2 published apps, 5-minute policy refresh, and 3 team members.
- Pro Plan ($249/month): The most popular option for growing applications, with 100 tools per app, 10 published apps, 30-second policy refresh, and 10 team members.
- Enterprise Plan (Custom): For large organizations requiring custom limits, features, and support.
All plans include file-based policies, CLI tools, community support, and a local development mode.
D2 FAQ
Traffic
Latest traffic
Status
Monthly traffic trend
- 2025-9: 461
- 2026-1: 0
- 2026-2: 0
- 2026-3: 177
- 2026-4: 0
- 2026-5: 296
Geography
Top 5 countries / regions
- 🇺🇸United States89.8%
- 🇮🇱Israel10.2%
Top keywords
| Keyword | Cost per click |
|---|---|
| artoo | $0.28 |
| rocoto | $0.80 |
| rocoto israel | $0.00 |
D2 Categories
D2 Jobs
D2 Embed Widget
Copy this embed code to place the badge on your blog, article, or product site and send readers directly to this ToolMage detail page.


















D2 Comments (0)
Sign in to comment.
Sign inNo comments yet.