PII detection
Support transcripts, form notes and uploaded documents carry personal data. A regular expression finds an email address. It does not find a name, a street address, or an account number written in prose.
The entities capability finds every span per type. Each span carries start and end, so your code can redact the text without a second search.
Describe the types
Send types as an object that maps a type name to a description. The description is what the model reads. You can also send an array of bare names, but each name then has to carry the whole definition.
The call above returns this response:
One broad name works less well. The same text with "types": ["pii"] returns two spans and misses three:
One described type per kind of personal data finds more.
Redact with the offsets
The API sorts entities by start ascending. Walk the list in reverse and cut each span out of the original string. Reverse order keeps every remaining offset valid.
The result:
Redaction destroys data. Use a low floor, near 0.5, and review the discarded spans. A missed span leaks; a wrong span only costs you a word.
Choose a probability floor
Measure these bands against your own data before you trust them. Golden sets and threshold tuning give you the numbers.
Non-English text
The extractor behind entities is multilingual. The same English type descriptions work against French text. This input:
returns these spans:
Write your type descriptions in English, whatever the language of the text. Every measured probe used English descriptions against non-English input.
Scale to a corpus
Send up to 32 documents per call in texts. The response is {"results": [...]}, one entry per document, in input order. The API runs a separate inference call per document, so a batch of 32 saves round trips, not work.
Documents over 2,000 characters run through overlapping windows. The API remaps the offsets back onto your original string. A single document holds up to 20,000 characters. Cost scales with the length of the text and the type descriptions you send: $0.04 per million input tokens and $0 per output token. See Pricing.
No API key is required during the launch period. A 529 response is the backpressure signal: retry it with backoff.
Next
- Entities — the full request and response contract.
- Languages — which capabilities handle non-English text.
- Long text and chunking — what happens past 2,000 characters.