AI

Scrub It Before the Model Sees It

#AI#Conn3x#Presidio#LiteLLM#Privacy#Self-Hosting#Open Source
James Conway7 min read

TL;DR: circuit-presidio runs Presidio, the open-source PII detector first built at Microsoft, on your own host. It finds names, email addresses, phone numbers and card numbers in a prompt and swaps them for placeholders before a model sees them. Put it in the LiteLLM gateway and every prompt gets the same treatment. It's best effort: one layer, never the only one.

Read the full walkthrough

Here’s a support ticket. Customer David Johnson, david@example.com, says card ending 4242 was charged twice. Somebody wants a summary, so in it goes, straight into the chat box.

Three pieces of personal data, and the model needs none of them to write that summary. Nobody meant any harm. People paste first and think later, and no policy document has ever changed that.

What does change it is a layer between the paste and the model. Presidio finds the obvious personal data and swaps it out, and circuit-presidio runs it on your own host with one Conn3x apply. The full walkthrough is on the Conn3x blog. This is the short version, and the bit about why.

One Layer, Never the Only One

Its own maintainers say it first

Before any config, the catch. Presidio’s maintainers put it plainly: “because it is using automated detection mechanisms, there is no guarantee that Presidio will find all sensitive information.” They’re right. It misses names, unusual ones especially, and now and then it flags something that was never personal at all.

So don’t sell it to your team as the thing that makes a document safe to send. What it does is cut down how many customer emails reach a model. That’s worth a lot. It just isn’t a guarantee, and a tool that’s honest about that is easier to trust than one that isn’t.

Two Small Services on Loopback

One finds it, the other swaps it

module "presidio" {
  source = "github.com/conn3xorg/circuit-presidio?ref=v0.1.1"

  hosts                = { gateway = "192.168.1.50" }
  ssh_private_key_file = "~/.ssh/id_ed25519"
}

Run conn3x init and conn3x apply, and you’ve got Presidio’s two HTTP services, each in Podman as a systemd service, pinned by tag and digest. The analyzer, on 127.0.0.1:5002, finds the personal data: spaCy’s English model for names and places, patterns and checksums for the rest. The anonymizer, on 127.0.0.1:5001, rewrites the text from what the analyzer found. The first apply pulls about 540 MB for the analyzer, which carries the language model, and 50 MB for the anonymizer.

Graphic: What the model gets. One prompt through circuit-presidio in three steps. 1, the prompt, pasted in: My name is David Johnson and my email is david@example.com, with the name and email outlined. 2, the analyzer at 127.0.0.1:5002 /analyze finds it: PERSON at characters 11 to 24, EMAIL_ADDRESS at characters 41 to 58. 3, the anonymizer at 127.0.0.1:5001 /anonymize swaps it: My name is <PERSON> and my email is <EMAIL_ADDRESS>. A strip along the bottom shows it in the gateway: app to LiteLLM with Presidio to the model. If Presidio is down: 500, nothing sent. Footer: best effort, it will miss some names. Source: circuit-presidio and circuit-litellm READMEs, 3 Dec 2026.

One sentence, three steps. Ports, spans and output are from the circuit-presidio README, checked 3 Dec 2026.
Read the graphic as text
  • The prompt: “My name is David Johnson and my email is david@example.com”.
  • The analyzer, POST http://127.0.0.1:5002/analyze, finds PERSON from 11 to 24 and EMAIL_ADDRESS from 41 to 58, each with a score.
  • The anonymizer, POST http://127.0.0.1:5001/anonymize, takes the same text and those findings and returns “My name is <PERSON> and my email is <EMAIL_ADDRESS>”.
  • In the gateway, circuit-litellm’s guardrails input runs this on every request before the model. If Presidio is down, LiteLLM returns a 500 and nothing is sent.
  • Best effort: in its maintainers’ words, there’s no guarantee it finds everything. Source: circuit-presidio and circuit-litellm.

A model can still summarise My name is <PERSON>. What it can’t do is repeat David’s name back to anyone.

Presidio doesn’t know your project code names or your ticket format, of course. You can teach it both, with a deny list for exact words and a regex for the rest, in the circuit’s analyzer_config.

Put It Where Every Prompt Goes

The gateway, not a script someone forgets to run

Calling Presidio by hand is fine for a script. Where it earns its keep is the path every prompt already takes: the LiteLLM gateway. LiteLLM has a Presidio guardrail built in, and circuit-litellm has passed it through as guardrails since v0.2.0:

module "litellm" {
  source     = "github.com/conn3xorg/circuit-litellm?ref=v0.2.3"
  depends_on = [module.postgres, module.presidio]

  # hosts, SSH key, database and models as in the README, then:
  guardrails = [{
    guardrail_name = "presidio-pii"
    litellm_params = {
      guardrail                    = "presidio"
      mode                         = "pre_call"
      default_on                   = true
      presidio_analyzer_api_base   = "http://127.0.0.1:5002"
      presidio_anonymizer_api_base = "http://127.0.0.1:5001"
      presidio_language            = "en"
      pii_entities_config = {
        PERSON        = "MASK"
        EMAIL_ADDRESS = "MASK"
        PHONE_NUMBER  = "MASK"
        CREDIT_CARD   = "BLOCK"
      }
    }
  }]
}

pre_call checks what goes to the model. default_on runs it on every request, not just the ones that ask. MASK swaps in a placeholder and BLOCK refuses the request outright. And because it lives in the gateway, anything that talks to LiteLLM gets the same masking, including the Open WebUI chat page from last week. Run the ticket from the top of this post through it and David Johnson and his email come out as placeholders. The last four digits of a card aren’t a card number, so “4242” stays, which is fine.

One honest flag on that config. Masking is what’s been tested. BLOCK refusing a request hasn’t been, and neither has post_call checking the answer.

The best part is what happens when Presidio isn’t there. On a 4 GB Rocky Linux 10 droplet with SELinux enforcing, a message with a name and an email reached the provider (a stand-in, for the test) as My name is <PERSON> and my email is <EMAIL_ADDRESS>, before and after a reboot. With the analyzer stopped, LiteLLM answered 500, and nothing reached the provider at all. If the guardrail can’t check a prompt, the prompt doesn’t go.

What It Won’t Do

So you don't find out on your own

CI applies it to Rocky Linux 10, Fedora 45, Ubuntu 24.04 and Debian 13. It checks that a second plan has nothing to change, sends the David Johnson sentence through both services and expects the exact output, and makes sure a made-up code name and employee ID get caught. Then it restarts both services and does it all again. By hand, on 2 GB Ubuntu and Rocky droplets, with SELinux enforcing on Rocky, port 5002 didn’t answer from outside, and both services came back after a reboot. The analyzer used about 850 MB, most of it the language model. The anonymizer, about 70.

And the gaps:

  • No guarantee. See the top of this post. It bears repeating.
  • No authentication. Anyone who can reach the ports can send it text, so it stays on loopback, and every plan warns you if listen_address says otherwise. Other hosts need circuit-caddy in front, with a password.
  • English only. The image ships spaCy’s English model and nothing else. Pattern recognizers need no model, so Italian fiscal codes in English text are fine. German names aren’t.
  • Upgrades are untested. Moving between presidio_version values hasn’t been tried yet.

Fewer Names, Not None

That's still a lot fewer

You won’t stop people pasting. In the Open WebUI post I said the same about personal chatbot accounts, and the answer then was to hand them something just as easy. Same answer here. Nobody on your team has to remember anything; the gateway does the remembering.

The README has every input, and examples/local runs it on a throwaway container. If you put it in front of your team, start a discussion and tell me what it caught that you didn’t expect.

// Let's talk

You have ideas.
I have IT solutions.

Fifteen minutes on Zoom is usually enough to tell whether I'm the right person for what you're building.

Denver, CO · Available for architecture, infrastructure, and DevOps engagements