LLM guardrails for GDPR: redacting personal data in prompts

Personal data reaching a model or its logs is a processing decision you must control. This page explains how to detect and mask identifiers before inference, what redaction misses, and the evidence to keep.

On this page

How LLM guardrails for GDPR redaction keep personal data out of prompts and logs

When an internal or customer-facing assistant sends staff or customer text to a model and writes that text to logs, personal data leaves the purpose it was collected for and spreads into places few teams have mapped. GDPR does not prescribe a specific tool, but it expects controllers to limit personal data to what is necessary (the data minimization principle in Article 5) and to apply appropriate technical and organizational measures to the processing, including its security (Article 32). Detecting and masking identifiers before inference, with a detector that runs in your own infrastructure, is one control that supports both duties. It does not replace a lawful basis, a retention decision or a transfer assessment. GDPR requires no audit, attestation or certificate, so the evidence is what your team can show a supervisory authority about how the control works. DeployOpen prepares those controls and that evidence in your environment, but does not issue audit reports, attestations or certifications.

The design choices start with the position of the detector. A self-hosted guardrail such as NeMo Guardrails, configured with input rails, or Guardrails AI, with a PII validator from Guardrails Hub, can run before the request reaches the model provider and before the prompt is written to a log. Put the same check in front of the gateway (for example LiteLLM or Apache APISIX) so that every application is covered by one policy rather than by per-app code. Decide which identifiers are masked (names, email addresses, account numbers, national identifiers, free-text details), whether a placeholder such as a token is restored in the response, and where the mapping between token and original value is held. The mapping is itself personal data and needs its own access control and retention rule. Confirm with your vendor and your own tests which entity types each validator or rail detects in your languages and document sources.

Which GDPR requirements redaction guardrails support and how to configure them

This table maps GDPR provisions that touch personal data in prompts to the guardrail function each one needs and where that function is configured. Read each row as a question to answer in your own design: what the article asks, what the rail must do, and which NeMo Guardrails or Guardrails AI component enforces it at the AI gateway. The main takeaway is that redaction supports several articles at once, but it does not discharge the controller's accountability on its own.

RequirementWhat the guardrail must doConfiguration in NeMo Guardrails or Guardrails AI, enforced at the gateway
Article 5 (principles, data minimization)Limit personal data reaching the model to what the task needs; detect identifiers in user input before inference and mask those not neededNeMo input rail calling a custom Python action that runs entity detection; Guardrails AI PII-style validator on input with a defined entity list; gateway rejects or rewrites requests that fail the check
Article 25 (data protection by design and by default)Apply redaction as a default for every route to the model, not as an option individual applications can skipShared guard configuration versioned in source control and loaded by all applications; gateway policy requires the guard call on every model route and blocks direct provider access
Article 32 (security of processing)Keep detection models and policy files inside the organization's infrastructure; prevent raw identifiers reaching logs, traces and cachesSelf-hosted detection models referenced in config.yml; output and log redaction applied before traces are written; gateway logging configured to store masked prompts only
Article 32 (restoring identifiers in responses)Where the answer must reference a masked identifier, restore it only for authorized users and only after the model callPlaceholder tokens mapped in a short-lived store keyed to the session; output rail reverses mapping only for permitted roles; mapping store encrypted and expired
Articles 33 and 34 (breach handling)Record each blocked or masked event with enough detail to scope an incident without storing the personal data itselfGuard decision logs with rule ID, entity type and timestamp written to the central log store; alert rules on spikes in detections or bypass attempts
Articles 44 to 50 (transfers)Confirm that prompts, masked text and any hosted guard or moderation API calls stay within the approved regions or on premisesGuard endpoints pinned to internal addresses in the gateway; any external classifier call disabled in config and verified by egress rules; confirm with counsel whether any transfer mechanism applies
Output checks on personal dataDetect personal data the model generates or recalls from its context, not only data the user typedNeMo output rail with the same entity detector; Guardrails AI output guard on the response; test with seeded identifiers to confirm coverage

Regex, named-entity models or LLM classifiers: which detector fits which data

Pattern validators use regular expressions and checksum logic to find identifiers that follow a fixed format. They are deterministic, fast and easy to explain to an auditor, which makes them a strong first layer for structured identifiers that appear in predictable shapes. Guardrails AI validators are one way to package this kind of check, and the same logic can run in front of a model call or in a log pipeline.

  • Structured identifiers: Patterns work well for email addresses, IBANs (with checksum validation), payment card numbers (with Luhn checks), national ID formats and phone numbers in a known country format.
  • Free-text names: Patterns miss personal names, nicknames and misspellings in free text, because a name has no fixed shape.
  • Context-dependent identifiers: Account references, case numbers or job titles that identify a person only when combined with other fields are outside what a pattern can judge.
  • Multilingual text: Formats differ by country and script, so each locale needs its own patterns and tests.
  • Maintenance: Every new format, such as a new internal ticket number, needs a new rule, which adds recurring tuning work.

Ask the team to run the patterns against a sample of real prompts and logs and report both the misses and the false matches, then review those results with the data protection officer before go-live.

Which open-source platforms fit a GDPR redaction layer

A GDPR redaction layer is assembled from a few distinct parts: a detection and rail framework, a gateway that enforces it, the model that receives only masked text, and the logs that must not become a second copy of personal data. The cards below cover the components most often evaluated for that job, with the license or version conditions to confirm before adoption.

NeMo Guardrails for input rails

NeMo Guardrails is Apache-2.0 licensed and provides input rails that run before a prompt reaches the model, so custom actions can call a detector and mask identifiers first. Its configuration uses config.yml, optional Python actions and Colang files, with Colang 1.0 as the default. Check whether your detection logic fits the rail model, and confirm which Python versions your platform team supports (3.10 to 3.13 are listed). Test each rail on your own sample prompts before go-live.

Guardrails AI validators

Guardrails AI is Apache-2.0 licensed and builds guards from validators published on Guardrails Hub, which can be chained together. A regex or entity-style validator can flag identifiers such as national numbers or email addresses before inference. Install validators separately, review each package's license and maintenance status, and confirm whether anonymous metrics reporting is enabled during guardrails configure. Validators catch patterns, so pair them with a tested entity list.

LiteLLM at the gateway

LiteLLM is an AI gateway that sits between applications and model providers, and its guardrails and logging features are where masking can be enforced once for every caller. It is MIT licensed except for the enterprise directory, so confirm which features your deployment needs fall outside that directory. Decide whether prompts are logged before or after masking, and whether restoration keys are held by the gateway or the application. Confirm the feature set against your pinned version.

Apache APISIX as AI gateway

Apache APISIX is an Apache-2.0 API gateway that also serves as an AI gateway, which lets a platform team enforce authentication, routing and request inspection in front of model endpoints. It suits organizations that already run APISIX for APIs and want one enforcement point for model traffic. Confirm whether masking and guard calls are available as plugins in your version, or whether they need a custom plugin or an upstream guard service. Document where the request body is inspected.

Langfuse trace storage

Langfuse is an open source LLM observability platform, MIT licensed except its ee directories, and it stores prompts, outputs and metadata for tracing. Any unmasked identifier sent to a model is also stored in traces, so the trace pipeline becomes a personal data store that needs its own retention rule and access controls. Confirm which ee features you would use, and test masking before traces are written. Check the license terms for each module you deploy.

Ollama or vLLM for on-premises inference

Ollama (MIT) and vLLM (Apache-2.0) serve open-weight models inside your own infrastructure, so masked prompts never leave your network. Masking reduces what the model sees, but the serving layer still holds prompts in memory and may write request logs, so confirm log settings and access rights. Check the license of each model you load separately from the engine license. Phoenix (Elastic License 2.0) and Dify (modified Apache License 2.0) appear in many stacks, and each carries conditions on hosting or multi-tenant use to review before adoption.

How a prompt is redacted before inference and restored afterwards

The sequence keeps identifiers out of the model and the logs by default, and restores them only in the narrow cases where the purpose requires it. Each step produces a checkable output, so the flow can be tested and evidenced.

  1. Receive the request at the AI gateway

    The application sends the user prompt to the self-hosted AI gateway, such as LiteLLM or Apache APISIX, rather than calling a model directly. The gateway authenticates the caller, attaches a request identifier and applies the policy set for that application. The gateway is also the single place where the redaction rule is enforced, so no application path can skip it. Done means every model call in scope shows up in the gateway's request log with its request identifier.

  2. Detect identifiers with the input rail

    An input rail runs before inference and scans the prompt for personal data such as names, email addresses, phone numbers, national identifiers, account numbers and postal addresses. Detection can combine pattern rules, such as regex validators, with named-entity models that run on your own servers. Your team should confirm which entity types the chosen tooling detects and test them on sample prompts drawn from your own data. Done means each prompt returns a list of detected spans with entity types and positions.

  3. Replace values with placeholders

    The rail swaps each detected value for a typed placeholder, for example a token that marks a person's name or an email address, and stores the original values in a mapping keyed to the request. The mapping is the only place the original values exist after this step, so access to it must be restricted and logged. Done means the prompt that leaves the rail contains no detected value, and a reviewer can confirm this by running the same test set and finding no unmasked spans.

  4. Send the redacted prompt to the self-hosted model

    The gateway forwards the masked prompt to a model served inside your infrastructure, such as one run with vLLM or Ollama, through an OpenAI-compatible endpoint. Because the endpoint is internal, the model never receives the original identifiers, and the application still gets a normal completion. Done means network records and endpoint logs show that the model received only the masked prompt for every request in the test set.

  5. Check the response with the output rail

    The model's answer passes through an output rail before anything is returned. The rail checks for placeholders the model may have invented or altered, for residual personal data the model generated from context, and for unsafe content that the policy blocks. A response that fails a check is blocked, regenerated or returned with a generic message, depending on the policy you set. Done means each response carries a recorded pass or fail result with the rule that produced it.

  6. Restore placeholders only where the purpose requires it

    Placeholders are swapped back to original values only for the outputs that need them, such as a drafted letter that must name the customer, and only for the user who is entitled to see that data. For most summaries, classifications and analytics uses, the response is returned with placeholders intact. The restoration step should be a named, configurable policy, not a default. Done means each restored response has a log entry showing which mapping was used and why restoration was permitted.

  7. Log masked text and discard the mapping

    The logging layer records the masked prompt, the masked response, rail decisions and request identifiers, and does not store the original values. The restoration mapping is itself personal data, because it links placeholders to identifiable people, so it is kept under its own retention limit and deleted when the purpose ends. Confirm with your privacy team how long mappings and logs are retained. Done means a sample of log records, searched for known test identifiers, returns none.

What evidence a supervisory authority or auditor may ask for

What records should a data protection authority expect for an assistant that processes personal data?

Expect a record of processing activities that describes the assistant as a processing activity, covering its purposes, categories of personal data, recipients, retention and security measures, in the form Article 30 of the GDPR describes. The redaction layer is part of that description, because it is the measure that limits which identifiers reach the model. Who maintains the record depends on your role: as controller you own it, and a partner can draft the technical sections from the deployed architecture. The record should name each self-hosted component, including the gateway, the guardrail service and the model server, and state where each one stores data. Keep the record current whenever the model, the policy set or the logging destination changes.

How should a redaction policy and its version history be documented?

The policy is the set of detection rules, entity types, masking or pseudonymization actions and exceptions that the guardrail layer applies, and it should be kept in version control. Each version should record what changed, who approved it, the date it took effect and the reason, such as a new identifier type or a false positive fix. In a NeMo Guardrails deployment, the policy lives in configuration files such as config.yml and any Colang files, and in Guardrails AI it lives in the guard definitions and the validators they chain. Tie every production deployment to a specific policy version so you can show which rules were active for any given request. Confirm with your partner how the repository, approval workflow and release tags will be set up before work begins.

What test results prove that personal data redaction works in practice?

Auditors will want measured detection and miss rates on data that resembles your production traffic, not only vendor claims. Build a labeled test set that includes the identifiers you handle, such as names, national identifiers, account numbers, contact details and free-text references, then record how many were detected, masked and missed for each policy version. The guardrail service produces the raw decisions, but the labeling and the metrics come from your test harness, and they should be rerun after every policy change. Report false positives too, because over-masking affects answer quality and is a documented trade-off. Confirm with your partner how the test set is built and whether it can be kept inside your environment.

Which guard decision logs should be kept, and for how long?

Keep logs that show what was detected, which rule fired, what action was taken and which policy version applied, without storing the raw personal data itself where a hash, token or category label is enough. The gateway, typically LiteLLM or Apache APISIX, and the guardrail service both produce these events, and an observability platform such as Langfuse or Phoenix can store them if they are self-hosted. Retention should be set in your own storage, with a documented period that matches your legal basis and internal policy. If the assistant is a high-risk AI system under the EU AI Act, Article 12(1) requires automatic event logging over the system's lifetime, and Article 19(1) requires providers to keep those logs for at least six months unless other law provides otherwise. Confirm with counsel whether that duty applies to your system.

What configuration change records should exist for guardrails?

Maintain a change log that records each modification to guard configuration, validator versions, model files, gateway routes and access rights, with the author, reviewer, timestamp and rollback point. The strongest evidence comes from infrastructure as code and pipeline logs, where every production change passes through a reviewed merge and a deployment record. Include upgrades of the guardrail library itself, since NeMo Guardrails and Guardrails AI release new versions regularly, and record the version in use. Where the platform uses Colang 1.0 and migrates to 2.x, keep the converted configuration and the manual review record, because NVIDIA states that converted configurations still need manual review. Ask your partner to deliver the change procedure alongside the platform.

What inputs does a data protection impact assessment need from the guardrail layer?

A DPIA, required under Article 35 of the GDPR when processing is likely to result in high risk, needs a description of the processing, an assessment of necessity and proportionality, the risks to individuals and the measures that address them. The guardrail layer supplies evidence for the measures section: the identifier types covered, the masking method, the test results on miss rates and the residual risks you accepted. It also documents where detection runs, which matters for transfers under Chapter V, since self-hosted detection models keep prompts inside your infrastructure. The DPIA remains the controller's document, and the assessment should be reviewed when the assistant's scope or data sources change. Your data protection officer should own the final text.

What processor terms should cover self-hosted AI components?

Even when every component runs in your own infrastructure, a contract should state the roles, the scope of any access a partner or vendor has, the security measures and the conditions for support and remote access. Under Article 28, when a third party processes personal data on your behalf, the controller and processor need a written agreement that sets these terms. Cover the implementation partner, any managed support you purchase, and any hosted service you still use, such as a model API or an external observability tool. Also confirm licensing terms of each component, since some open-source projects restrict hosted or managed use. Check the processor agreement with your legal team, and ask the partner to list every system that touches data during deployment and support.

What redaction tooling alone does not satisfy

A redaction layer reduces what reaches a model, but it does not decide whether processing is lawful, erase what was already stored, or prove the controls work over time. The cards below cover the gaps a controller must close with decisions, contracts, organizational measures and ongoing testing.

Lawful basis and purpose still needed

Masking a name before inference does not answer why the assistant processes personal data at all. The controller must record a lawful basis under Article 6 and a specific purpose, then check that prompts, retrieved documents and model outputs stay within that purpose. Redaction rules should be written from that purpose, so that identifiers the business genuinely needs are not stripped and identifiers it does not need are never sent.

Historical logs and files

Redaction applies to new prompts from the moment it is deployed. Earlier chat histories, traces, vector indexes, uploaded files and backups may still hold the original identifiers. Ask which stores contain raw prompts and outputs, who can read them, and how deletion requests reach each copy. Decide whether logs should store masked text only, and set retention for both application logs and observability traces.

Memorization and inference from context

Masking a direct identifier does not stop a model from inferring a person from a job title, location, case detail or rare combination of facts in the same prompt. Models can also reproduce personal data seen during training or fine-tuning if such data was used. Test outputs with realistic but synthetic prompts that combine quasi-identifiers, and confirm with the model provider what data was used for training and whether the hosted service retains prompts.

Transfers depend on hosting and contracts

Redacting a prompt does not change where the remaining personal data is processed. If a hosted model endpoint, gateway, logging service or support tool runs outside the EEA, Chapter V of the GDPR applies to whatever personal data still leaves the EEA. Confirm the processing location of every component, the data processing agreement terms with each provider, and whether any transfer mechanism is in place. Self-hosting the detector and model keeps these questions narrower, but does not remove them.

Organizational measures under Article 32

Article 32 requires controllers and processors to implement appropriate technical and organizational measures for security of processing. Detection rules are only one technical measure. Access control to the gateway, to unmasked mapping tables used for restoration, and to logs must be defined and reviewed. Staff who build prompts, write rails or review blocked requests need training on what counts as personal data and how the guardrail is meant to be bypassed or not.

Detector accuracy needs continuous testing

Named-entity detectors and regex validators miss identifiers in new languages, misspellings, OCR errors and unusual formats, and they flag non-personal text as personal. Accuracy shifts when users change how they write and when models or policies are updated. Treat detection as a measured control: keep a labelled test set drawn from your own content, record miss and false-positive rates per data category, and rerun the set after every change to rails, validators or models.

How much does GDPR redaction for LLM prompts cost and how long does it take?

What does GDPR redaction for LLM prompts cost overall?

The total depends on scope, and no price is published here. The cost has four main parts: compute for the detection models that find identifiers, engineering time to write and tune redaction policies, testing against the organization's own sample prompts and documents, and the logging design that records what was masked without storing the personal data itself. Compute is usually recurring because detectors run on every request, while policy design, integration and initial testing are one-time work. Costs rise with the number of languages, document types, applications calling the gateway and the volume of traffic. Ask any partner to split the quote into one-time and recurring items, and to state which environment, models and log retention periods each line assumes.

How long does a GDPR redaction rollout take?

No duration is fixed in advance, so confirm the timeline in writing before work starts. Engagements are usually fixed-scope, and the schedule follows from the agreed deliverables: which applications and gateways are covered, how many identifier types are in scope, whether responses must be restored, and how much testing on the organization's own data is required. A narrow scope with one application and a short list of identifiers will take far less time than a multi-application rollout that also needs approval workflows and log review. Ask for milestones tied to deliverables, including the test results that will be accepted as the basis for going live.

Can our own engineering team build GDPR redaction in-house?

Yes, many teams can build a first version with open-source components, and the NeMo Guardrails and Guardrails AI libraries both provide mechanisms for input checks and custom validators. The harder work is operational: writing policies for your identifier types, tuning them against false positives and misses on your own data, placing them at an AI gateway, and keeping logs free of the personal data they are meant to protect. Internal teams should estimate whether they have the time, skills and on-call capacity to maintain detection rules as models, applications and languages change. A partner can take on the build, and your team keeps ownership of policies and decisions.

What do our DPO, security and business owners need to contribute?

Each group has a distinct role. The data protection officer should define which categories of personal data must be masked, the lawful basis for any restoration of identifiers in responses, and the retention rules for logs. Security should review where detection models run, how the gateway enforces policies, how access to logs and mapping tables is controlled, and how the controls are tested. Business owners should identify the assistants and workflows in scope, the expected use cases and the acceptable cost of a false positive, such as a legitimate name being masked. Agree these decisions before the build starts, because they shape the policy configuration and the test plan.

Do we need a GDPR certification or audit to use redaction?

No. The GDPR does not require an audit, attestation or certificate for redaction or any other control. Certification under Article 42 is voluntary, is issued for at most three years by accredited certification bodies or supervisory authorities, and does not reduce the controller's or processor's responsibility for compliance. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications. Ask your legal and DPO teams which evidence they need to demonstrate data minimization and security of processing under Article 32.

What should we ask for in a quote for redaction work?

Ask for a written scope that lists the applications, gateways and models covered, the identifier types and languages in scope, and the sample data used for testing. The quote should separate one-time work (design, integration, initial tuning, documentation) from recurring costs (detector compute, log storage, policy updates, retesting after model changes). Request the acceptance criteria for detection and masking tests, how false positives and misses will be reported, and who owns the policies after handover. Confirm the hosting location of every component, the log retention period and the support terms after go-live. DeployOpen works from a written scope and provides a quote from it, and does not publish a price list.

Build, partner or hosted redaction API

Building in-house means your own engineers assemble the redaction path from open-source parts, typically NeMo Guardrails or Guardrails AI for the rails and validators, a self-hosted AI gateway to enforce them, and a detection model or pattern set that runs inside your network. Personal data stays in your infrastructure from the first token, which keeps the transfer analysis under Chapter V of the GDPR simple. The cost is ownership: your team writes the policies, tunes detection against your own documents, handles upgrades and keeps the logs that show what was masked.

  • Data location: prompts never leave your cloud accounts or data centers, so no third-country transfer arises from the guard itself.
  • Engineering effort: staff must write Colang or validator configurations, build test sets and maintain them as models and prompts change.
  • Upgrades: you own version pinning and regression tests for each library release.
  • Evidence: you must design the logs that record redaction decisions without storing the identifiers themselves.
  • Skills: security engineers and application developers both need working knowledge of the chosen framework.

Confirm internally who will own policy changes after launch and how much time that role has in its plan.

What to confirm with your DPO and the vendor before go-live

Before any model sees a prompt through the redaction layer, the legal basis for each use case should be recorded with your data protection officer. Redaction reduces what reaches the model, but it does not decide whether the processing itself is lawful. Ask the DPO to confirm the basis for each assistant and each logging purpose separately, because a support chatbot, an internal HR helper and a debugging trace may each need a different assessment. Also agree which identifiers are in scope: names, email addresses, account numbers, national identifiers, free-text health or financial details, and identifiers that appear inside uploaded files. Write that list down and version it, since the detector configuration is only as complete as the list it implements.

Next, confirm whether logs keep raw text. Gateway logs, chat history, observability traces and guardrail decision logs can each store the prompt before or after masking. If a tracing tool such as Langfuse records the unredacted input, the redaction step has not reduced exposure for that store at all. Confirm the retention period for each store, who can read it, and whether the blocked or masked events are recorded without the personal data itself. Restoration mappings are a related risk: the table that links placeholders back to real values is personal data in its own right. Ask who holds that table, where it is encrypted, how long it lives, and whether it is deleted when the session ends.

Finally, check license terms for each component, because some restrict how you may offer the software to others. Arize Phoenix is licensed under the Elastic License 2.0, which prohibits providing the software to third parties as a hosted or managed service, so confirm with counsel whether your internal use or any partner-operated setup falls within that limit. If Open WebUI is used as the chat front end, its license clause 4 restricts altering or removing branding except within stated limits, including deployments with no more than 50 end users in any rolling 30 day period, so confirm whether your deployment qualifies or whether written permission is needed. Ask your implementation partner to provide a written inventory of every component, its license and the terms that apply to your use, and to confirm that no detector model used for redaction carries terms that conflict with your deployment.

How DeployOpen scopes, deploys and documents GDPR redaction guardrails

DeployOpen plans, implements, integrates, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure. For GDPR redaction guardrails, that means defining which personal data must stay out of prompts and logs, building detection and masking in the client's environment, and handing over evidence that the controls work as written.

How we scope

  • Inventory the personal data categories, source systems and user groups that reach the assistant, and record where prompts and logs are stored.
  • Agree which identifiers are masked before inference, which are restored in responses and which are blocked outright, in a written scope.
  • Define the test data, sample prompts and acceptance criteria that will be used to measure redaction misses before work starts.

How we build

  • Deploy NeMo Guardrails or Guardrails AI in the client's own cloud account, data center or air-gapped network, with detection running locally.
  • Wire input rails to the AI gateway so masking happens before any model call, and configure log redaction for traces and blocked requests.
  • Run adversarial and edge-case tests, including names, free text and identifiers split across turns, and tune policies against the agreed criteria.

How we hand over

  • Deliver version-controlled policy files, configuration, deployment code and runbooks that the client's own team can operate and review.
  • Document the redaction scope, known gaps, test results and the data flows that show personal data is minimized at each step.
  • Provide evidence packs that help the client's assessors review data minimization and security of processing, without implying certification.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work begins, and quoted from that written scope.
  • Ongoing support, upgrades of guardrail libraries and continuous testing of redaction quality are available as a retainer.
  • Re-test redaction after model, prompt template or data source changes, and confirm with your legal and privacy team how changes to GDPR affect your policies.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.