[DOCS-16431] Move AI Guard middleware to its own page #41933
Preview links (active after the build_preview check completes)
New or renamed files
https://docs-staging.datadoghq.com/melissa.amos/aiguard-middlewares-ia/security/ai_guard/middleware
Modified Files
https://docs-staging.datadoghq.com/melissa.amos/aiguard-middlewares-ia/security/ai_guard/
https://docs-staging.datadoghq.com/melissa.amos/aiguard-middlewares-ia/security/ai_guard/setup/automatic_integrations
https://docs-staging.datadoghq.com/melissa.amos/aiguard-middlewares-ia/security/ai_guard/setup/sdk
@avara1986 Technical question here.
@avara1986 Technical question here.
python For LiteLLM Proxy, register middleware in the proxy process, not in the agents behind the proxy. Define the middleware in its own Python module that the proxy can import, such as a module on the proxy's `PYTHONPATH`, and import that module from the `guardrails.py` file that imports the AI Guard guardrail. LiteLLM Proxy can load `guardrails.py` more than once, but Python imports your module only one time, so the middleware is registered one time:
# aiguard_middleware.py, on the proxy's PYTHONPATH
from ddtrace.aiguard.middleware import AIGuardMiddleware, register_middleware
class InputOnly(AIGuardMiddleware):
...
register_middleware(InputOnly())
python# guardrails.py
import aiguard_middleware # noqa: F401
from ddtrace.aiguard.integrations.litellm import DatadogAIGuardGuardrail
__all__ = ["DatadogAIGuardGuardrail"]
Redaction never runs, so result.messages holds the original, unredacted messages. Automatic integrations don't use the returned evaluation, so this only affects SDK callers that forward result.messages.
- SDK calls return an `ALLOW` action with the reason `skipped by middleware`, no attack tags or Sensitive Data Scanner findings, and the original messages. A skipped request never reaches AI Guard, so sensitive data redaction doesn't apply: if you forward `result.messages` to the model, the model receives the unredacted messages.
Approved these changes.
avara1986
melamos
<!-- Note: Please remember to review the Datadog Documentation Contribution Guidelines if you have not yet done so. -->
What does this PR do? What is the motivation?
Fixes DOCS-16431
Editorial and IA pass on #41417. Middleware works with every Python integration method, not only automatic integrations, so this PR moves the middleware content from the SDK page to its own page, Control Evaluations with Middleware, with rewrites to bring the content in line with tech writing best practice. Custom tags for SDK calls stay on the SDK page.
Also adds middleware mentions on the main AI Guard landing page for discoverability.
Merge readiness
AI assistance
Restructured and edited with Claude Code. Technical claims were checked against the
dd-trace-py4.17.0 source.For Datadog employees:
<name>/<description>convention and include the forward slash (/). If you've already created your PR with an incorrect branch name, please rename your branch and open a fresh PR./reviewto run an automated check that catches common issues before a Documentation team member reviews your PR.Additional notes
TODOcomments for the author: where to register middleware for LiteLLM Proxy, and whether skipped SDK calls return unredacted messages.request.sourceis"auto"for manual integrations too, andrequest.integrationincludes"litellm".security/ai_guard/_index.md) is a file that #41417 doesn't otherwise touch.