Building a Privacy-Safe AI Pipeline: What Goes Between Your Data and the Model
- Last reviewed:
- 06 Mins read
An AI data protection policy states what should happen. It does not stop an employee, or an application, from sending a customer record to a model. Controls that sit in the data path do that. This article describes a gateway pattern for the data path, what each control can and cannot achieve, and a checklist for testing it. It is general information, not legal advice.
Why a policy alone does not reach the prompt
The GDPR requires the controller to implement “appropriate technical and organisational measures” and to be able to demonstrate that processing complies (Art. 24). Security measures must include, where appropriate, pseudonymisation and encryption, and “a process for regularly testing, assessing and evaluating the effectiveness” of the measures (Art. 32). The second requirement is the one policy-only approaches fail: a policy that has never been tested against real traffic has no evidence of effectiveness.
A prompt is assembled at runtime from user input, retrieved documents and tool outputs. A rule in a handbook applies to the first of these at best. Controls therefore need to sit where the request is assembled and sent.
The gateway pattern
The pattern is simple to state. Every call to an external model passes through one internal service, and applications cannot reach the vendor endpoint directly (enforced at the network level, for example by allowing outbound traffic to the vendor only from the gateway). The gateway performs these steps in order:
- Authenticate and classify the request. Identify the application, the user and the data classification of the sources involved.
- Detect personal data and secrets in the assembled prompt.
- Act on what is found: block, redact, or replace with tokens, depending on the use case.
- Send to the approved endpoint with the approved settings (retention, region, no-training).
- Process the response, restoring tokens only where the use case needs it and the user is entitled to the data.
- Log metadata about the call without storing the sensitive content.
The value is not in any single step. It is that there is exactly one place to inspect, test and change behaviour, and one place that can be shown to an auditor or a DPO.
What the detection step can and cannot do
Open-source tools such as Microsoft Presidio combine named entity recognition, regular expressions, rule-based logic and checksum validation to find entities such as names, locations and card numbers in text. The project itself states that, because detection is automated, “there is no guarantee that Presidio will find all sensitive information” and recommends additional protections alongside it.
That limitation sets the design rule: detection reduces exposure but cannot be the only safeguard. Structured identifiers (card numbers, national ID formats, email addresses) are matched well by patterns and checksums. Names in free text, indirect identifiers and context that identifies a person without naming them are harder. Organisations should measure detection quality on their own data, in their own languages, rather than rely on a vendor’s description, and should treat the result as a recall figure to be tracked over time.
Redaction, tokenisation and what they mean legally
Replacing a name with a reversible token, with the mapping stored in your own environment, is pseudonymisation. Under Art. 4(5) the data can be attributed to a person with the additional information, and the EDPB’s pseudonymisation guidelines say such data remains personal data. The step is still worthwhile: it is a recognised security measure under Art. 32(1)(a), and it reduces what a vendor, a log file or a leaked transcript reveals. But it does not take the project outside the GDPR, so the processor contract and transfer mechanism are still needed (Art. 28).
Irreversible redaction (deleting the identifier and keeping no mapping) is stronger, but it is not automatically anonymisation either. The EDPB’s draft Guidelines 02/2026 ask whether individuals can be singled out, linked or inferred from what remains, and the draft lists AI models and synthetic datasets among the sources of inference risk, alongside record-level data. The companion article on anonymisation covers the test.
Synthetic data for development and testing
Synthetic data is a sensible way to build and test a pipeline without production records, for example to test the detection step. The caveat is the one above: if synthetic records are generated from real ones, whether they can be linked back or used to infer facts about real people has to be assessed. If the synthetic set is generated from invented values with no real source, that question does not arise.
Vendor-side settings are part of the pipeline
The gateway should set, and tests should verify, the vendor options that control retention and training. These differ by vendor and by feature. OpenAI states that zero data retention is available only to eligible customers with prior approval, and that some endpoints are not eligible (API data controls). Anthropic states that features such as the Files API and batch processing are not eligible for zero data retention, and that flagged content may be retained for up to two years regardless of arrangement (API and data retention). A gateway that silently switches an application to a feature outside the ZDR scope defeats the contract. Pin the feature set per application.
What the pipeline does not solve
- Model output. The model’s response can contain personal data it was given, or content that is wrong about a real person. Output checks are a separate control.
- Memorisation in fine-tuned models. Researchers extracted verbatim training sequences, including personal data, from GPT-2 (Carlini et al.). A gateway protects prompts, not training sets.
- Misuse around the gateway. Staff can paste data into consumer tools. OpenAI states that content from Free, Plus and Pro accounts may be used for training unless the user opts out (help centre). Network blocking and approved alternatives matter as much as the gateway.
- Legal basis and transparency. Technical controls do not supply a lawful basis or notices to data subjects. They also do not decide whether a DPIA is needed (Art. 35).
For a structured view of LLM privacy risks and mitigations, the EDPB Support Pool of Experts published a report. It was prepared by an external expert and does not represent the EDPB’s official position.
A pipeline control test sheet
This is my own checklist, not a standard or a regulatory requirement. Each control has a test that produces evidence, because Art. 32 asks for testing, not intent.
| Control | Test | Pass signal | Fail signal |
|---|---|---|---|
| Single egress path | Attempt a direct call to the vendor from an application server | Call is blocked | Call succeeds |
| Detection coverage | Run a labelled sample of real-format records (or realistic synthetic ones) through the gateway | Recall measured, threshold agreed with the DPO, tracked per release | No measurement, or measured only on vendor demos |
| Free-text handling | Insert indirect identifiers (job title plus site plus date) into a test prompt | Behaviour is defined (block, review or flag) | Passes unchanged with no policy |
| Token mapping | Check where the mapping is stored and who can read it | Stored in your environment, access logged, expiry set | Stored beside the prompt logs |
| Vendor settings | Inspect the live request and account configuration | Retention and no-training settings match the contract, per feature | Settings assumed from the sales deck |
| Logging | Inspect log contents after a test with fake personal data | Metadata only, or content with a defined retention | Full prompts stored indefinitely |
| Output handling | Ask the model to repeat earlier input | Policy defined for what the user sees | No output check |
| Retest | Date of last full test | After each model, vendor or data change | Tested once at launch |
Actions
- Block direct vendor access from application networks and route all calls through one gateway.
- Measure detection recall on your own data and languages before go-live, and agree a threshold with the DPO.
- Decide, per use case, between block, redact and tokenise, and document that the tokenised result is still personal data.
- Pin vendor settings and feature sets per application, and verify them against the contract.
- Schedule the test sheet to rerun on every model, vendor or data-source change.
Sources
- GDPR Art. 4, Art. 24, Art. 28, Art. 32, Art. 35 (reproductions of Regulation (EU) 2016/679; the EUR-Lex original could not be opened in this session)
- EDPB, pseudonymisation guidelines news release, 17 January 2025
- EDPB, draft Guidelines 02/2026 on Anonymisation
- EDPB Support Pool of Experts, AI Privacy Risks and Mitigations: LLMs (I read the listing page, not the full report)
- Microsoft Presidio
- OpenAI API data controls; OpenAI consumer training policy
- Anthropic, API and data retention
- Carlini et al., Extracting Training Data from Large Language Models