| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/ai-gateway/features/dlp/ | [Back] [Original] |
Data Loss Prevention (DLP) for AI Gateway helps protect your organization from inadvertent exposure of sensitive data through AI interactions. By integrating with Cloudflare's proven DLP technology, AI Gateway can scan both incoming prompts and outgoing AI responses for sensitive information, ensuring your AI applications maintain security and compliance standards.
AI Gateway DLP leverages the same powerful detection engines used in Cloudflare's Data Loss Prevention solution to scan AI traffic in real-time. The system analyzes both user prompts sent to AI models and responses received from AI providers, identifying sensitive data patterns and taking appropriate protective actions.
AI Gateway DLP can scan:
The system works with all AI providers supported by AI Gateway, providing consistent protection regardless of which models or services you use.
DLP inspects the text content of request and response bodies as they pass through AI Gateway. The following details apply:
When DLP response scanning is enabled and a client sends a streaming request ("stream": true), AI Gateway buffers the complete provider response before running DLP inspection. This differs from requests without DLP, where streamed chunks are forwarded to the client as they arrive.
Because of this buffering:
DLP scanning runs after a cache miss, when AI Gateway forwards the request to the provider and receives a response. The following table describes how each DLP outcome affects caching:
| DLP outcome | Response cached | Behavior |
|---|---|---|
| Pass (no findings) | Yes | The response is cached normally according to your gateway cache settings. |
| Flag | Yes | The response is cached normally. DLP findings are attached to the cf-aig-dlp response header and recorded in logs, but the original response is returned to the client. |
| Block | No | The provider response is discarded and replaced with a DLP error response (status 400). |
Cache hits skip DLP scanning. When a subsequent identical request matches a cached response, AI Gateway serves it directly from cache without re-running DLP. This is safe because only responses that already passed DLP (or were flagged, not blocked) are cached. However, if you update your DLP policies after a response has been cached, the cached response is not re-evaluated. It continues to be served until the cache TTL expires.
If you need DLP policy changes to take effect immediately, you can bypass the cache for new requests using the cf-aig-skip-cache header. For more information, refer to Caching.
DLP policies are configured at the gateway level and apply uniformly to all requests passing through that gateway. There is no per-request header to select specific DLP profiles or to bypass DLP scanning for individual requests.
If you need different DLP policies for different use cases (for example, per-tenant policy variance in a multi-tenant application), the recommended approach is to create separate gateways with different DLP configurations and route requests to the appropriate gateway based on your application logic.
AI Gateway DLP uses the same detection profiles as Cloudflare One's DLP solution. Profiles are shared account-level objects, so you can reuse existing predefined or custom profiles across both Gateway HTTP policies and AI Gateway DLP policies.
Key differences from Cloudflare One Gateway DLP:
For more information about Cloudflare's DLP capabilities, refer to the Data Loss Prevention documentation.
To enable DLP for your AI Gateway:
| Web Proxy Viewer | New URL | Original Page |