One call
curl https://layahost.com/v1/decide \
-H "Authorization: Bearer $LAYAHOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hi, this is Anna Kowalski, my card 4111 1111 1111 1111 was charged twice. Call me on +1 415 555 0132.", "template": "pii"}'
{
"decision": true,
"probability": 0.99,
"entities": [
{ "type": "person", "text": "Anna Kowalski", "start": 12, "end": 25, "score": 0.95 },
{ "type": "credit_card", "text": "4111 1111 1111 1111", "start": 35, "end": 54, "score": 0.99 },
{ "type": "phone", "text": "+1 415 555 0132", "start": 85, "end": 100, "score": 0.95 }
],
"redacted": "Hi, this is [PERSON], my card [CREDIT_CARD] was charged twice. Call me on [PHONE].",
"template": "pii"
}
decision answers “does this text contain personal data?”, so you can also branch on it in a decision flow. Ask for some types only with "options": ["email", "phone"].
What it finds
person</code>, <code>email</code>, <code>phone</code>, <code>address</code>, <code>credit_card</code>, <code>iban</code>, <code>ip_address</code>, <code>date_of_birth</code>, <code>national_id</code>, <code>account_number</code>, <code>username</code>, <code>password.
Two layers work together. Formats with a checksum or a strict shape are matched by rules: emails, card numbers (Luhn check), IBANs (mod-97), IP addresses and phone numbers (libphonenumber). Names, addresses, dates of birth, ID and account numbers, usernames and passwords come from GLiNER PII, an open (Apache-2.0) span-detection model, which reads context instead of patterns.
How accurate it is
Measured on held-out samples of two public datasets. A found entity counts as correct when its type matches and it overlaps the labelled one by at least half.
| Dataset | Precision | Recall | F1 |
|---|---|---|---|
| NVIDIA Nemotron-PII (200 documents) | 0.97 | 0.88 | 0.92 |
| Gretel synthetic finance PII (250 documents) | 0.67 | 0.69 | 0.68 |
Measured 2026-09-27. Gretel’s labels are incomplete (real-looking emails and names left unlabelled) and its texts are financial message formats, so its precision is pessimistic. Nemotron-PII is better labelled but may overlap the model’s training data, so treat it as optimistic. Weakest types: usernames and passwords inside codes. Test on your own text with a test set.
layahost or Microsoft Presidio?
Presidio is Microsoft’s open-source PII toolkit: you run its analyzer and anonymizer services yourself, choose NLP models, and write recognizers. It is the right choice when data must never leave your network, or when you need images, many custom recognizers or reversible anonymisation.
| Presidio | layahost pii | |
|---|---|---|
| Setup | Run and update analyzer and anonymizer services, pick spaCy or transformer models | An API key |
| Detection | Patterns plus NER models, extensible with your own recognizers | Checked patterns plus a PII-specific GLiNER model |
| Output | Entities; anonymisation operators (replace, mask, hash, encrypt) | Entities with offsets, a [TYPE]-redacted copy, and a yes/no answer |
| Where data goes | Your own servers | Our servers in Helsinki (EU), processed in memory, not stored |
| Cost | Free software, your compute | One decision per text: $15 per million, $1 free to start |
Common uses
- Before an LLM call: redact support tickets and chats before you send them to a third-party model, then restore names from the offsets if you need to.
- Before logging: keep request logs and analytics free of emails and card numbers.
- In an agent: screen tool output and fetched pages, together with the
prompt_injectiontemplate. See LLM guardrails. - In n8n or over MCP: the same template is available in the
n8n-nodes-layahostnode and the layahost MCP server.
FAQ
Do you keep the text?
No. Text is processed in memory and not written to disk; logs keep the verdict and metadata for 7 days, and the text only if you turn it on. Details in data handling.
Which languages?
English is measured above. Emails, card numbers, IBANs and IP addresses are found in any language. Phone numbers are read with US conventions, so numbers in international format (+48 512 345 678) are found everywhere, but local formats from other countries can be missed. Names and addresses in other languages are found less reliably.
Is layahost affiliated with Microsoft?
No. Presidio is Microsoft’s open-source project, named here for comparison only.