LLM Privacy Shield API
Strip personal data (emails, phone numbers, SSNs, credit cards, IPs, API keys) out of text before it reaches an LLM, then put the real values back in the model's response. Works with any LLM, including OpenAI, Anthropic, and Gemini. Sub-millisecond, fully in-process, so your data never goes to a third party.
Subscribing on RapidAPI gives you your x-rapidapi-key, then you call the endpoints at llm-privacy-shield.p.rapidapi.com.
Endpoints
POST /api/redactwith body{ text, strategy?, detectNames? }. Returnsredacted,token_map,entities, andcounts. Strategies aretokenize(default, reversible),mask, andremove.POST /api/restorewith body{ text, token_map }. Returnsrestored.GET /api/healthfor a liveness check.
How a real user wires it in
A common case is a support tool that uses GPT to summarize customer messages. You redact the message, send only the safe version to the model, then restore the real contact details in the summary your agent reads. The customer's personal data never leaves your server. The same three steps work with any model. Just change the call in step two for Anthropic or Gemini.
// Real example: summarize a customer support email with GPT,
// without sending any personal data to OpenAI.
const SHIELD = "https://llm-privacy-shield.p.rapidapi.com";
const shieldHeaders = {
"content-type": "application/json",
"x-rapidapi-host": "llm-privacy-shield.p.rapidapi.com",
"x-rapidapi-key": "YOUR-RAPIDAPI-KEY"
};
async function summarizeSafely(customerEmail) {
// 1. Redact PII before the text leaves your server.
const { redacted, token_map } = await fetch(SHIELD + "/api/redact", {
method: "POST",
headers: shieldHeaders,
body: JSON.stringify({ text: customerEmail })
}).then(res => res.json());
// customerEmail:
// "Hi, my confirmation went to john@acme.com but nothing arrived.
// Please call me back on 415-555-0132."
// redacted:
// "Hi, my confirmation went to [EMAIL_1] but nothing arrived.
// Please call me back on [PHONE_1]."
// 2. Send only the safe version to your model. OpenAI is shown here.
// Anthropic and Gemini work the same way, just swap this call.
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "Summarize this support email in one sentence." },
{ role: "user", content: redacted }
]
});
const summary = completion.choices[0].message.content;
// 3. Put the real contact details back for your support agent.
const { restored } = await fetch(SHIELD + "/api/restore", {
method: "POST",
headers: shieldHeaders,
body: JSON.stringify({ text: summary, token_map })
}).then(res => res.json());
return restored;
}The two calls, at a glance
// The two calls, at a glance (through RapidAPI)
const HOST = "https://llm-privacy-shield.p.rapidapi.com";
const headers = {
"content-type": "application/json",
"x-rapidapi-host": "llm-privacy-shield.p.rapidapi.com",
"x-rapidapi-key": "YOUR-RAPIDAPI-KEY" // from your RapidAPI dashboard
};
const r = await fetch(HOST + "/api/redact", {
method: "POST",
headers,
body: JSON.stringify({ text: "Email john@acme.com about invoice 4521" })
}).then(x => x.json());
// r.redacted => "Email [EMAIL_1] about invoice 4521"
// r.token_map => { "[EMAIL_1]": "john@acme.com" }
const back = await fetch(HOST + "/api/restore", {
method: "POST",
headers,
body: JSON.stringify({ text: modelReply, token_map: r.token_map })
}).then(x => x.json());
// back.restored => the model reply with the real values put backBuilt for compliance-sensitive LLM workflows (GDPR, HIPAA). Name detection uses a low-confidence heuristic and is off by default.