How LiteLLM enforces Microsoft Purview DLP on AI traffic
If your organization already runs Microsoft Purview data loss prevention, the question is how to make AI prompts and responses pass through the same policies instead of building a second set of rules for AI traffic. LiteLLM addresses this with a built-in Microsoft Purview guardrail, which is the supported method for this pattern. The guardrail sends the text of a prompt or response to the Microsoft Graph processContent API, where Purview evaluates it against the DLP policies that target the registered app. The LiteLLM gateway then acts on the result. In pre_call mode, the check runs before the request reaches the model provider, so a blocked prompt never leaves your infrastructure. In post_call mode, the check runs on the model's response before it returns to the caller. Both modes can block. A third option, logging_only, evaluates traffic and records the outcome without stopping it.
The choice between blocking and audit-only mode is a policy decision with operational consequences, and it should be made per guardrail before rollout. Start in logging_only mode if you need to learn how often real prompts match your DLP rules, which rule types fire on developer traffic, and whether false positives will disrupt teams. Moving to blocking mode changes user experience immediately, so plan for help desk questions, an exception path for legitimate work, and a named owner who reviews matches. Confirm with your Purview administrator which sensitive information types and policy scopes apply to the app, because the guardrail can only enforce what the Purview policy covers. Confirm also how your LiteLLM version handles guardrail failures and timeouts, since a failed Graph call can either let traffic through or stop it, and that behavior determines how much you rely on the check.
The guardrail depends on identity. Each request must be attributed to an Entra user so that Purview can apply user-scoped policies, which is why keys are bound to the Entra object ID of the end user. Shared keys or service accounts without a user identity weaken the control, because Purview cannot tell whose data it is evaluating. Before going live, verify that the Entra app registration holds the permissions named in the LiteLLM Microsoft Purview documentation, that admin consent has been granted, and that the Purview DLP policy targets this app. Then test with a few known test users in both modes and review the Purview activity and LiteLLM logs together to confirm that the same prompt produces the same outcome in each system. The LiteLLM Microsoft Purview documentation lists the exact configuration keys, which should be checked against the release you plan to run.
What you need before configuring Purview with LiteLLM
Five things have to be in place before the Purview guardrail can evaluate any request: an Entra app registration with the right Graph permissions, a Purview DLP policy that targets that app, a working LiteLLM proxy backed by PostgreSQL, and a tenant and network path that lets the gateway call Microsoft Graph. Confirm each one in your own environment before changing the gateway configuration.
Entra app registration
Create a dedicated app registration in the Entra tenant that holds the Purview DLP policy. The gateway authenticates to Microsoft Graph as this app, so its client ID, client secret or certificate, and tenant ID become the credentials LiteLLM stores. Keep the registration separate from applications used for other purposes so its permissions and sign-in logs stay easy to review. Record who owns the registration and how the secret is rotated.
Purview guardrail docsThree Graph permissions
The registration needs InformationProtectionPolicy.Read.All, ProtectionScopes.Compute.User and Content.Process.User. Each one covers a different step: reading the policy, computing which policies apply to a user, and submitting prompt and response content for evaluation. Ask your identity team to confirm whether admin consent is required in your tenant and who approves it. Review the permissions again whenever the guardrail configuration changes.
Purview DLP policy targeting the app
Create a Purview DLP policy that covers the app registration so Graph evaluates AI traffic against it. Without a policy that targets the app, processContent has no rules to apply and the guardrail cannot block anything. Decide which sensitive information types matter for your prompts and responses, and test the policy on sample text before enabling blocking. Confirm with your compliance team which policy owner signs off on changes.
Working LiteLLM proxy with PostgreSQL
Virtual keys need a PostgreSQL database, so the proxy must be running with that database before you bind keys to Entra object IDs. Verify that key creation, team assignment and model restrictions work on a test key first. If you run more than one proxy instance, the production guide calls for Redis 7.0 or newer for shared state. Keep the master key in a secret manager, not in configuration files.
Virtual keys docsTenant and network path
The gateway must reach Microsoft Graph endpoints and the Entra login service over outbound HTTPS, and the end users' Entra object IDs must be available to the proxy when it handles a request. Check any egress firewall, proxy, or private DNS rules that sit between the gateway and Microsoft services. If your tenant uses conditional access that blocks service principals from unfamiliar locations, add a policy exception for the gateway's egress addresses.
Licensing in your tenant
No licensing terms for Purview DLP, Entra or the Graph features above were included in the research for this page, so confirm them directly with Microsoft and your account team. Check which Purview and Entra plans your tenant holds, whether AI interaction DLP is included, and whether any feature needs an add-on. Also confirm your LiteLLM edition, since Enterprise features are needed for some governance controls.
Configuring the Purview guardrail in sequence
This sequence connects Microsoft Purview DLP to LiteLLM in the order the pieces depend on each other: identity and permissions first, then the Purview policy, then gateway configuration and key binding. Each step ends with a check so you can confirm the control works before you rely on it.
Register an Entra app for the guardrail
Your Entra administrator creates an app registration in the tenant that will hold the Purview evaluation identity for the LiteLLM gateway. Record the application (client) ID and the directory (tenant) ID, and store the client credential in your secret manager rather than in the config file. Check that the app appears in the Entra admin center under app registrations and that its ID matches what you will put in the LiteLLM config.
Grant the three Graph permissions
Add the Microsoft Graph application permissions InformationProtectionPolicy.Read.All, ProtectionScopes.Compute.User and Content.Process.User to the app. Confirm with your Entra administrator whether admin consent is required in your tenant, and record who granted it. Check that the permission list shows all three with consent status granted before moving on, because the processContent calls fail without them.
Create a Purview DLP policy targeting the app
In the Microsoft Purview portal, create a DLP policy whose scope includes the Entra app you registered, so that Purview evaluates content sent through it. Choose the sensitive information types your organization must protect, such as card numbers or national identifiers. Check the policy status and, if your tenant offers it, the policy simulation or test mode, to confirm that the policy is active and targets the app.
Add the Purview guardrail to the LiteLLM config
Add the Microsoft Purview guardrail to your LiteLLM proxy configuration, supplying the tenant ID, app ID and secret reference from step one. Keep the secret out of the file itself. Restart or reload the proxy using your normal change process. Check the proxy logs at startup for a message that the guardrail loaded without configuration errors.
Enable pre_call and post_call blocking
Set the guardrail mode so that pre_call checks the prompt before it reaches the model provider and post_call checks the response before it returns to the caller. Blocking at both points is the enforcement setting. Check with a test prompt that contains a sensitive information type matching the Purview policy: the request should be rejected before any provider call, and the rejection should appear in the proxy logs.
Bind virtual keys to Entra object IDs
For each user or service that calls the gateway, look up the user's Entra object ID and bind the LiteLLM virtual key to it, so Purview evaluates requests against that person's identity and policy scope. Keep a record of which keys map to which object IDs. Check by sending a request with a bound key and confirming in the Purview audit records that the evaluation shows the expected user, and by testing an unbound key to see how it behaves.
Test logging_only before enforcing
Switch the guardrail to logging_only for a trial period so matches are recorded without blocking traffic. Review which prompts and responses would have been stopped, and adjust the Purview policy scope or sensitive information types where results are noisy. Check that matched events appear in the Purview activity records and the LiteLLM logs, then switch back to pre_call and post_call blocking once the results match your expectations.
How a prompt travels from the user through LiteLLM to Purview and the model
The request starts at the user's client with a LiteLLM virtual key, which the proxy maps to the user's Entra object ID. Before the model call, the Purview guardrail sends the prompt to Microsoft Graph processContent through the Entra app, and a DLP match in a blocking mode stops the request. Once the model responds, the same check runs on the output in post_call. Check that each key is bound to the right Entra object ID and that the mode is set deliberately for each route.
Request path through the proxy, Graph and the model, with pre_call and post_call checks marked.
Mapping LiteLLM keys to Entra users and Purview policies
This table maps each LiteLLM and Microsoft identity element to the object it binds to, the permission it needs, and the blocking behavior it produces. Read it top to bottom to trace one request from a virtual key to a Purview evaluation, then check each binding in your own tenant before enabling blocking.
| Element | What it binds to | What it controls or requires | What to confirm |
|---|---|---|---|
| LiteLLM virtual key | Entra object ID of the end user | Lets the guardrail send the correct user's context to Purview for evaluation | Each key maps to one user object ID, not a shared service account |
| Entra app registration | Purview DLP policy scope | The DLP policy must target this app so processContent calls are evaluated against it | The policy scope names the registered app, not only users |
| InformationProtectionPolicy.Read.All | Graph policy lookup | Reads sensitivity and DLP policy definitions the guardrail depends on | Admin consent is granted in the tenant |
| ProtectionScopes.Compute.User | Protection scope calculation | Determines which policies apply to the user before content is processed | Compute is called with the user object ID |
| Content.Process.User | processContent calls | Permits submission of prompt and response content for DLP evaluation | Confirm it is application-level consent and covers both directions |
| pre_call mode | Request before the model call | Evaluates the prompt and blocks the request if a policy matches | Blocking happens before any provider receives content |
| post_call mode | Response after the model call | Evaluates the model output and blocks the response if a policy matches | Provider already processed the prompt, so check your data handling terms |
| logging_only mode | Evaluation without enforcement | Records matches for review without stopping traffic | Use for tuning policies; switch to blocking only after review |
Choosing between blocking and audit-only modes
Start with the logging_only mode when the Purview policies have not yet been tuned to your data. In this mode the guardrail sends prompts and responses to the processContent evaluation and records what matched, but it does not stop the request. Users see normal model output, so the rollout does not interrupt work while you learn which policies fire on real traffic.
- Users: requests complete as before, so no one is blocked while the policy is still being tuned.
- Logs: matches are recorded in the gateway logs and the Purview side, which gives you the evidence to review.
- False positives: you can review matches by key and Entra user and decide which policies are noise before enforcement.
- Coverage gaps: you also learn which traffic paths the guardrail does not see, such as endpoints it is not attached to.
Before leaving audit mode, confirm with the security team which policies and sensitivity labels will block, who reviews matches and how fast, and what the exception process is for legitimate business use.
pre_call blocking evaluates the prompt before the request reaches the model provider. If Purview reports a matching DLP policy, the gateway rejects the call, so the sensitive content never leaves your infrastructure toward the provider. This is the control most organizations want for prompts, because it prevents disclosure rather than recording it after the fact.
- Users: callers receive an error for blocked prompts, so client applications and developer tools need to handle that error clearly.
- Logs: the blocked request and the policy match are logged, which supports investigation and user coaching.
- False positives: every false positive stops a legitimate request, so exception handling and user guidance matter more than in audit mode.
- Latency: the evaluation runs before the model call, so each request waits for the Graph response.
Confirm with the security team how blocked callers are notified, which teams can request an exception, and whether a failed evaluation should block or pass the request.
post_call blocking evaluates the model response after it returns. It is useful when the risk is sensitive content coming back out of a model, for example when a prompt was allowed but the response reproduces restricted material from context it was given. The model has already been called by the time the check runs, so this mode controls what the caller receives rather than what the provider receives.
- Users: the caller receives a blocked response instead of the model output, which can confuse users who expected an answer.
- Logs: the provider call has already happened, so the log shows that data was sent and that the response was withheld.
- False positives: a response may be withheld even though the prompt was acceptable, so review patterns that come from retrieval or document content.
- Cost: tokens for blocked responses are still consumed, which matters for budgets and chargeback.
Confirm with the security team whether a provider-side data exposure from the prompt is acceptable under your policies, since post-call checks do not prevent it.
Choose the mode per policy and per key population, not for the whole gateway at once. A common sequence is to run audit mode for a defined group of keys, review matches for a set period, then move high-confidence policies to pre_call blocking while keeping lower-confidence policies in audit. Post-call blocking is added where response-side exposure is a stated risk. The sequence should be recorded in the change plan so that each mode switch has an owner and a rollback path.
- Scope: switch modes for a limited set of Entra-bound keys first, so the blast radius of a false positive stays small.
- Ownership: name who approves each switch from audit to blocking.
- Rollback: keep the previous configuration in version control so the mode can be reverted quickly.
- Evidence: keep match reviews and approvals as records for your compliance team.
- Permissions: confirm the Entra app permissions and the Purview policy targeting the app are in place before any enforcement.
Before switching modes, confirm with the security team the policy list, the exception path, the log retention period and the escalation contacts for blocked traffic.
Securing the Entra app and the gateway
The Entra app, its client credential and the LiteLLM gateway together decide who can read DLP verdicts and who can weaken them. Each card below closes one path an attacker or an over-privileged administrator could use to switch enforcement off or reach content the policy was meant to protect.
Grant only the three Graph permissions
The Purview guardrail needs InformationProtectionPolicy.Read.All, ProtectionScopes.Compute.User and Content.Process.User. Grant exactly these as application permissions on the Entra app, and do not add broader Graph scopes for convenience. Ask your identity team to review the consent record after admin consent is granted, and confirm in the LiteLLM Microsoft Purview docs that no other permission is required for your version.
Purview guardrail docsStore the app secret in a vault
The client secret or certificate that lets LiteLLM call Graph is equivalent to the authority to evaluate content as your tenant. Keep it in a secret manager, not in the proxy config file or environment variables checked into Git. Set a rotation schedule, prefer a certificate where your Entra setup supports it, and confirm with your edition whether the secret manager integrations in the LiteLLM Enterprise docs fit your vault.
Restrict the master key
LITELLM_MASTER_KEY must start with sk- and grants full administrative control of the proxy, including creating keys and changing guardrails. Limit who can read it, keep it out of application teams' hands, and use virtual keys bound to Entra object IDs for everyday traffic. Rotate it after any administrator leaves the group that held it.
Limit who can change guardrail modes
Switching a Purview guardrail from blocking to logging_only removes enforcement for every key that uses it, often without any visible change to callers. Make mode changes an admin-only action, require a second reviewer for changes to production, and document the approved modes per environment so that a change away from blocking is a deliberate decision.
Keep an audit trail of mode changes
Record who changed a guardrail mode, when, from which configuration version and why. Keep these records outside the gateway so that a compromised admin session cannot erase them. The LiteLLM Enterprise docs describe audit logs; confirm with the vendor that the events you need, such as guardrail mode edits and admin logins, are captured for your edition before you rely on them.
Confirm edition features before design
Audit logs, secret manager integrations and SSO beyond the free user limit are Enterprise features in the LiteLLM Enterprise docs. Confirm the edition you will run against each control in this list before the design is approved, and record the answer in the design document. Where a control is not available in your edition, plan a compensating control such as external change logging on the configuration repository.
Why Purview checks fail or match the wrong traffic
This table lists the failures teams hit most often when wiring Purview DLP into LiteLLM, with the likely cause and the fix for each. Read it as a checklist to run through before enabling blocking mode, since several failures look like model errors or silent passes rather than configuration problems.
| Symptom | Likely cause | Fix |
|---|---|---|
| Graph calls fail with authorization errors | Admin consent not granted for InformationProtectionPolicy.Read.All, ProtectionScopes.Compute.User or Content.Process.User | Have a Global or Privileged Role Administrator grant consent for the app registration, then confirm the three permissions show as granted |
| Requests pass with no DLP evaluation | The Purview DLP policy does not target the Entra app, so no protection scope applies to its traffic | Add the app to the DLP policy scope and confirm the policy is on in the intended mode before testing |
| Policy matches some users but not others | Keys are not bound to the Entra object ID of the end user, so the guardrail cannot tell whose content it is evaluating | Bind each virtual key to the user's object ID in Entra, and reject keys that lack a binding in your provisioning process |
| Users outside the policy get no checks | Their accounts are not in the scope of the DLP policy, often because scope was set to a group that was never updated | Scope the policy to a group that matches your onboarding flow, and test with an account from each group that uses the gateway |
| Streamed answers are not fully inspected | post_call evaluates a complete response, and streamed chunks reach the caller before the full text is available to check | Confirm with your LiteLLM version how streaming is handled, decide whether to block streams or rely on pre_call checks, and test with a streamed request |
| Blocks appear in logging_only mode | Mode is set in more than one place, or a policy in blocking mode applies to the same traffic through another configuration | Check the guardrail config for each key, team and model, then compare the effective mode in the logs with the expected mode |
Testing Purview enforcement before users depend on it
Test Purview enforcement with a written plan before any team sends production prompts through the gateway. Build a set of labeled synthetic samples that map to the sensitive information types your Purview DLP policy covers, such as made-up card-like numbers, fictional national identifiers and invented customer records. For each sample, record the expected outcome in every mode: in blocking mode, pre_call should stop the request before the model call and post_call should stop a response that contains flagged content; in logging_only mode, the request should reach the model and the event should appear in the logs and in Purview's activity records. Include at least one case per direction (prompt and response) and one case that should pass cleanly, so you can confirm both false negatives and false positives.
Test the identity path as deliberately as the content path. Use a test key bound to a test Entra user object ID and confirm that the guardrail evaluates against that user's policy scope. Then run the same samples with a key that is not bound to a user, and with a user outside the DLP policy's scope, and record what happens. The result you need is a documented answer to the question of what Purview evaluates when the identity is missing or out of scope. Confirm this behavior with the LiteLLM Microsoft Purview documentation and with your own Purview configuration, since the bound identity determines which policy applies.
Roll out in stages: start with logging_only on one pilot team's keys, review the findings with the security team for a fixed period you agree in advance, then move that team to blocking mode before adding the next team or key group. Keep the synthetic test set and its results, including the mode, key, user, expected and actual outcome and the log references, as evidence for the security review. Store prompts used in tests in a repository the security team controls, and do not replace synthetic samples with real customer data to make tests look more representative.
Questions buyers ask before hiring help with Purview and LiteLLM
How much does it cost to put Purview DLP in front of LiteLLM?
No fixed price applies, because the cost comes from the written scope: how many teams, keys and policies are involved, how many Entra tenants and Purview policies you run, and how much testing you want before go-live. DeployOpen does not publish a price list, and a quote follows from that written scope. The one-time parts are the Entra app registration, the Purview DLP policy, the LiteLLM guardrail configuration, the key binding work and the blocking versus audit-only test cycle. Recurring costs include the Microsoft Purview licensing your tenant already carries, the LiteLLM Enterprise license if you need it for the guardrail (confirm this in the LiteLLM Enterprise docs for your version), and internal time to review DLP matches. Ask any provider for a quote that separates these items.
How long does a Purview and LiteLLM DLP rollout take?
Duration depends on how many teams and policies are in scope, how quickly your Purview admins can create the DLP policy targeting the app, and how long you run audit-only mode before switching to blocking. No duration figure has been established for this work, so ask any provider for a timeline tied to your written scope. A reasonable plan separates three phases: tenant preparation (app registration and permissions), a logging_only audit period so you can see what would have been flagged, and then pre_call or post_call blocking for the teams you approve. Confirm the audit period length with your own compliance team before the work starts.
What does our team need to provide before the work starts?
You need access to the Microsoft Entra tenant and permission to register an application, along with an admin who can create and scope Purview DLP policies. You also need a LiteLLM deployment you control, with a PostgreSQL database for virtual keys (the LiteLLM virtual keys docs state this requirement) and a way to map each key to the Entra object ID of the person who uses it. Your team should also name the data owners who decide what counts as sensitive, and the people who will review DLP matches. Confirm these owners and access paths in your own tenant before scoping, because gaps there usually extend the timeline more than the technical build does.
Can our internal team do this without a partner?
Yes, if your team already runs Entra, Purview and a self-hosted LiteLLM deployment, and has someone who can read Graph API permission grants and DLP policy scopes. The work is configuration rather than custom code, but it spans three administrative domains: identity, data protection and the AI gateway. Teams without experience in all three often spend most of their time on permission consent and key binding rather than on the guardrail itself. A partner is most useful for a fixed-scope build with written acceptance tests, or for a security test that checks whether a user can bypass the binding. Decide based on which of those skills you already have.
What drives the scope of a Purview DLP engagement?
The main drivers are the number of teams, virtual keys and model routes that send traffic through the guardrail, the number of Purview DLP policies and sensitive information types you apply, and whether you run one Entra app or several. Each key must be bound to the Entra object ID of its end user, so a large key inventory adds mapping and verification work. Mixed blocking and audit-only modes across teams also add test cases. Ask for the scope as a list of teams, keys, models, policies and modes, and ask which items are one-time setup and which need ongoing administration.
What permissions does the Entra app need for Purview DLP through LiteLLM?
The LiteLLM Microsoft Purview docs list three Microsoft Graph permissions for the Entra app registration: InformationProtectionPolicy.Read.All, ProtectionScopes.Compute.User and Content.Process.User. The app also needs a Purview DLP policy that targets it, so that Graph processContent evaluates the prompts and responses. Grant only these permissions, record who consented to them, and confirm with your identity team that admin consent follows your tenant's approval process. Review the exact consent screens in your own tenant, since Microsoft's naming and consent flow can change.
What is the difference between blocking and audit-only mode?
In blocking mode, the LiteLLM Purview guardrail evaluates content against your DLP policies and stops the request, either before the model call (pre_call) or after the response (post_call). In audit-only mode, the guardrail runs as logging_only, so matches are recorded but traffic still reaches the model. Most teams run audit-only first to measure false positives and to learn which teams send sensitive data, then switch approved teams to blocking. Set the switch criteria in writing before go-live, and confirm with your compliance owner which records must be kept during the audit period.
How DeployOpen scopes and delivers the Purview integration
DeployOpen approaches Microsoft Purview DLP policies with LiteLLM as a fixed-scope implementation inside your own infrastructure. We agree what the guardrail covers, which keys map to which Entra users, and which policies run in blocking or audit-only mode before any build starts. Ongoing support is available as a retainer once the integration is live.
How we scope
- Inventory which AI traffic, endpoints and teams the Purview guardrail must screen before work starts.
- Confirm the Entra tenant, app registration ownership and the three Graph permissions the integration requires.
- Agree in writing which Purview DLP policies target the app and which mode each one runs in.
How we build
- Register the Entra app and configure the LiteLLM Microsoft Purview guardrail in your self-hosted gateway.
- Bind virtual keys to Entra user object IDs so every screened request maps to a named end user.
- Test pre_call and post_call blocking and logging_only audit behavior against sample prompts and responses.
How we hand over
- Document the app registration, permission grants, DLP policy targets, key-to-user binding and rollback steps.
- Record test results for blocking and audit-only modes so your security and compliance teams can review them.
- Walk your operations team through configuration changes, mode switches and what to check when a screen fails.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover.
- Retest the guardrail after LiteLLM upgrades or changes to Purview DLP policies and Graph permissions.
- Ask your quote to separate one-time build effort from recurring support and retest effort.

