1. Get a key
Subscribe to the free plan on RapidAPI (500 requests a month) and copy your key from the code panel.
Set it as RAPIDAPI_KEY. Want to see it work first? Try the live demo, no signup.
2. curl
curl -X POST https://eu-pii-redaction.p.rapidapi.com/redact \
-H "content-type: application/json" \
-H "X-RapidAPI-Host: eu-pii-redaction.p.rapidapi.com" \
-H "X-RapidAPI-Key: $RAPIDAPI_KEY" \
-d '{"text": "Dear Mr Hansen, please call me on +45 32 12 34 56."}'Response:
{"redacted": "Dear Mr [PERSON_1], please call me on [PHONE_1].",
"entities": [{"type": "PERSON", "start": 8, "end": 14, "placeholder": "[PERSON_1]"},
{"type": "PHONE", "start": 34, "end": 49, "placeholder": "[PHONE_1]"}]}
3. Python
pip install eu-pii-redact
from eu_pii_redact import Redactor
with Redactor() as r: # reads RAPIDAPI_KEY
redaction = r.redact(ticket_text)
answer = ask_llm(redaction.text) # the model only sees placeholders
print(redaction.restore(answer)) # real values back in the answer
Texts longer than 50,000 characters are split automatically, with consistent placeholders. Package: eu-pii-redact on PyPI.
4. JavaScript / TypeScript
// Node 18+ (or any runtime with fetch). No package needed.
const HOST = "eu-pii-redaction.p.rapidapi.com";
async function redact(text) {
const res = await fetch(`https://${HOST}/redact`, {
method: "POST",
headers: {
"content-type": "application/json",
"X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
"X-RapidAPI-Host": HOST,
},
body: JSON.stringify({ text }),
});
if (!res.ok) throw new Error(`Redaction failed: ${res.status}`);
const { redacted, entities } = await res.json();
const originals = {};
for (const e of entities) originals[e.placeholder] ??= text.slice(e.start, e.end);
return { redacted, originals };
}
function restore(text, originals) {
// Longest placeholder first, so [PERSON_1] never touches [PERSON_10].
return Object.keys(originals)
.sort((a, b) => b.length - a.length)
.reduce((out, p) => out.split(p).join(originals[p]), text);
}
const { redacted, originals } = await redact("Hi, my name is Karina Dahl. Refund to DK50 0040 0440 1162 43.");
console.log(redacted); // send this to your LLM
console.log(restore("Hi [PERSON_1], we refunded [IBAN_1].", originals));
5. LangChain
pip install "eu-pii-redact[langchain]"
from eu_pii_redact.langchain import protect
safe_llm = protect(llm) # any model or chain that takes a string
safe_llm.invoke("Draft a reply to Karina Dahl about her refund")
6. n8n
In n8n: Settings → Community Nodes → Install and enter n8n-nodes-eu-pii-redact.
Put EU PII Redaction → Redact before your AI node and Restore after it.
7. AI assistants (MCP)
claude mcp add eu-pii-redact -e RAPIDAPI_KEY=your-key -- uvx eu-pii-redact
For Claude Desktop, download the one-click bundle. The redact_file
tool redacts files without their contents ever entering the conversation.
Options
"types": ["EMAIL", "IBAN"]: only some kinds of data (PERSON, EMAIL, PHONE, IBAN, CREDIT_CARD, EU_VAT, NATIONAL_ID, IP_ADDRESS)."mode": "mask": asterisks instead of placeholders.- Each entity has
start/endoffsets in your original text; national IDs also havecountryandscheme.