# Veil (`veil-1`): PII detection and redaction

Find and mask 29 kinds of personal data.

Veil finds personal data in text (names, emails, phones, street addresses, card numbers, IBANs, national IDs, passwords, API keys and more) and returns each with offsets. Ask for `redact` and you also get the text back with every one replaced.

Redact with type tags (`[EMAIL]`), a fixed mask, or numbered placeholders (`[PERSON_1]`, `[PERSON_2]`) that keep who-said-what readable for an LLM.

- **Price:** $0.02 per 1,000 texts. One unit per text up to 2,000 characters; longer texts are split into 2,000-character chunks and each chunk is a unit.
- **Languages:** Multilingual, tested in English, Russian, Arabic, French, Korean, Turkish
- **Input:** A string, or an array of up to 64 strings to run as a batch.
- **Batch:** yes, up to 64 inputs per call
- **Status:** live
- **Built on:** [Horizon-Labs/pii-redactor-small](https://huggingface.co/Horizon-Labs/pii-redactor-small), Apache-2.0 (training data CC-BY-4.0), 141M (mmBERT-small encoder)

## Request

```bash
curl https://labs.greatwork.company/v1/run \
  -H "Authorization: Bearer $GWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"veil-1","input":"Hi, I'm Dana Whitfield, my account email is dana.whitfield@example.com and my card ending 4242 4242 4242 4242 was charged twice. Call me at (512) 555-0187."}'
```

## Options

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `input` | string or string[] | yes | | A string, or an array of up to 64 strings to run as a batch. |
| `redact` | string (none \| type \| mask \| numbered) | no | `"type"` | How to rewrite the text: `type` gives [EMAIL], `mask` gives ████, `numbered` gives [PERSON_1], `none` skips the rewrite. |
| `types` | string[] | no |  | Only detect these types (e.g. `["email", "phone", "credit_card"]`). |
| `threshold` | number | no | `0.5` | Score at or above which a span is returned. |

## Output

| Field | Type | Description |
|---|---|---|
| `redacted` | string | The text with every span replaced (unless `redact: "none"`). |
| `spans` | object[] | `type`, `text`, `start`, `end`, `score` for each piece of personal data. |
| `counts` | object | How many of each type. |

The response envelope is always `{"id", "object": "run", "model", "created", "output", "usage": {"units", "unit", "cost_usd", "cost_micros"}, "latency_ms"}`. With an array input, `output` is an array in the same order.

## Examples (real outputs from our servers)

### Support email

```json
{
  "model": "veil-1",
  "input": "Hi, I'm Dana Whitfield, my account email is dana.whitfield@example.com and my card ending 4242 4242 4242 4242 was charged twice. Call me at (512) 555-0187."
}
```

```json
{
  "redacted": "Hi, I'm [PERSON], my account email is [EMAIL] and my card ending [CREDIT_CARD] was charged twice. Call me at [PHONE].",
  "spans": [
    {
      "type": "person",
      "text": "Dana Whitfield",
      "start": 8,
      "end": 22,
      "score": 0.9794
    },
    {
      "type": "email",
      "text": "dana.whitfield@example.com",
      "start": 44,
      "end": 70,
      "score": 0.9949
    },
    {
      "type": "credit_card",
      "text": "4242 4242 4242 4242",
      "start": 90,
      "end": 109,
      "score": 0.9988
    },
    {
      "type": "phone",
      "text": "(512) 555-0187",
      "start": 140,
      "end": 154,
      "score": 0.9987
    }
  ],
  "counts": {
    "person": 1,
    "email": 1,
    "credit_card": 1,
    "phone": 1
  }
}
```

78 ms, $0.00002.

### Numbered

```json
{
  "model": "veil-1",
  "input": "Call notes: Sofia Ramirez asked Daniel Okafor to send the signed lease to Daniel's office at 18 Harbor Road, Portland. Sofia's number is +1 503 555 0148.",
  "redact": "numbered"
}
```

```json
{
  "redacted": "Call notes: [PERSON_1] asked [PERSON_2] to send the signed lease to Daniel's office at [STREET_ADDRESS_1], [LOCATION_1]. [PERSON_1]'s number is [PHONE_1].",
  "spans": [
    {
      "type": "person",
      "text": "Sofia Ramirez",
      "start": 12,
      "end": 25,
      "score": 0.9638
    },
    {
      "type": "person",
      "text": "Daniel Okafor",
      "start": 32,
      "end": 45,
      "score": 0.9148
    },
    {
      "type": "street_address",
      "text": "18 Harbor Road",
      "start": 93,
      "end": 107,
      "score": 0.9925
    },
    {
      "type": "location",
      "text": "Portland",
      "start": 109,
      "end": 117,
      "score": 0.8735
    },
    {
      "type": "person",
      "text": "Sofia",
      "start": 119,
      "end": 124,
      "score": 0.5785
    },
    {
      "type": "phone",
      "text": "+1 503 555 0148",
      "start": 137,
      "end": 152,
      "score": 0.9955
    }
  ],
  "counts": {
    "person": 3,
    "street_address": 1,
    "location": 1,
    "phone": 1
  }
}
```

71 ms, $0.00002.

### Leaked secret

```json
{
  "model": "veil-1",
  "input": "deploy failed, here's my config: STRIPE_KEY=sk_live_51HxQe2LkdIwHu7ix and the server is at 10.0.4.17 with password Tr0ub4dor&3",
  "redact": "mask"
}
```

```json
{
  "redacted": "deploy failed, here's my config: STRIPE_KEY=████████████ and the server is at █████████ with password ███████████",
  "spans": [
    {
      "type": "secret",
      "text": "sk_live_51HxQe2LkdIwHu7ix",
      "start": 44,
      "end": 69,
      "score": 0.9784
    },
    {
      "type": "ip_address",
      "text": "10.0.4.17",
      "start": 91,
      "end": 100,
      "score": 0.9511
    },
    {
      "type": "password",
      "text": "Tr0ub4dor&3",
      "start": 115,
      "end": 126,
      "score": 0.9985
    }
  ],
  "counts": {
    "secret": 1,
    "ip_address": 1,
    "password": 1
  }
}
```

77 ms, $0.00002.

## Good for

- Strip PII from support tickets before sending them to an LLM
- Clean logs and transcripts
- Anonymize datasets for analytics
- Mask card numbers and secrets in chat

## Limits and caveats

- Not a guarantee of anonymization: review anything you'll publish.
- Every date is tagged, not only birth dates.
- Unusual ID formats may be partly masked.
- Types: account_id, age, bank_account, coordinate, credit_card, credit_card_cvv, date, date_of_birth, device_id, driver_license, email, ip_address, license_number, location, mac_address, medical_id, national_id, organization, passport, password, person, phone, postcode, secret, street_address, tax_id, url, username, vehicle_id.
