> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PII Redaction

export const ModelBadges = ({models}) => {
  return <div className="flex flex-wrap gap-2 -mt-3 mb-3 not-prose">
      {models.map(model => <span key={model} className="inline-flex items-center rounded-full bg-green-500/15 px-2.5 py-0.5 text-xs font-mono text-green-700 dark:text-green-400 ring-1 ring-inset ring-green-500/30">
          {model}
        </span>)}
    </div>;
};

<ModelBadges models={["universal-3-5-pro", "u3-rt-pro", "universal-streaming-english", "universal-streaming-multilingual"]} />

Automatically detect and redact personally identifiable information from streaming transcripts in real time.

## Overview

Streaming PII Redaction lets you automatically detect and remove personally identifiable information from your streaming transcripts in real time. When enabled, the API redacts PII in **final turns only** before sending them to the client.

<Warning>
  **Final turns only**

  PII redaction only applies to final turns. When `redact_pii` is `true`,
  `include_partial_turns` defaults to `false` automatically so no unredacted
  text reaches the client. Only set `include_partial_turns` to `true` if you
  explicitly want partial (non-final) turns, which will contain unredacted PII
  alongside the redacted final turns.
</Warning>

When you enable PII redaction, your final turns will look like this:

* With `hash` substitution: `Hi, my name is ####!`
* With `entity_name` substitution: `Hi, my name is [PERSON_NAME]!`

<Tip>
  **Pre-recorded PII redaction**

  For PII redaction on pre-recorded audio, including generating redacted audio files, see [Redact PII from transcripts](/guardrails/redact-pii-from-transcripts).
</Tip>

## Connection parameters

| Parameter               | Type    | Required | Default                                               | Description                                                                                                                                                                                                                                                                                                                                  |
| ----------------------- | ------- | -------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `redact_pii`            | boolean | Yes      | `false`                                               | Enable PII text redaction. Only applies to final turns.                                                                                                                                                                                                                                                                                      |
| `redact_pii_policies`   | array   | No       | All                                                   | PII entity types to redact. Over the raw WebSocket, pass a JSON-encoded array of policy names (e.g. `["person_name","phone_number"]`). The SDKs accept a native list/array. If omitted and `redact_pii` is `true`, all detected PII is redacted. See [PII policies](/guardrails/redact-pii-from-transcripts#pii-policies) for the full list. |
| `redact_pii_sub`        | string  | No       | `hash`                                                | Replacement scheme. `hash` replaces PII with `#` characters, `entity_name` replaces with `[ENTITY_TYPE]`.                                                                                                                                                                                                                                    |
| `include_partial_turns` | boolean | No       | `false` when `redact_pii` is `true`, otherwise `true` | Whether to include partial (non-final) turns. Defaults to `false` automatically when PII redaction is enabled, so no unredacted text reaches the client. Set to `true` only if you explicitly want to receive partial turns, which will contain unredacted PII.                                                                              |

## Quickstart

Enable PII redaction by setting `redact_pii` to `true` when you open the WebSocket. Optionally pass `redact_pii_policies` to limit which entity types are redacted, and `redact_pii_sub` to choose the replacement scheme.

<Tabs>
  <Tab language="python" title="Python" default>
    ```python theme={null}
    import json

    CONNECTION_PARAMS = {
        "sample_rate": 16000,
        "speech_model": "universal-3-5-pro",
        "redact_pii": True,
        "redact_pii_policies": json.dumps(["person_name", "phone_number", "email_address"]),
        "redact_pii_sub": "entity_name",
    }
    ```
  </Tab>

  <Tab language="python-sdk" title="Python SDK">
    ```python theme={null}
    client.connect(
        StreamingParameters(
            sample_rate=16000,
            speech_model="universal-3-5-pro",
            redact_pii=True,
            redact_pii_policies=["person_name", "phone_number", "email_address"],
            redact_pii_sub="entity_name",
        )
    )
    ```
  </Tab>

  <Tab language="javascript" title="Javascript">
    ```javascript theme={null}
    const CONNECTION_PARAMS = {
      sample_rate: 16000,
      speech_model: "universal-3-5-pro",
      redact_pii: true,
      redact_pii_policies: JSON.stringify([
        "person_name",
        "phone_number",
        "email_address",
      ]),
      redact_pii_sub: "entity_name",
    };
    ```
  </Tab>

  <Tab language="javascript-sdk" title="JavaScript SDK">
    ```javascript theme={null}
    const transcriber = client.streaming.transcriber({
      sampleRate: 16_000,
      speechModel: "universal-3-5-pro",
      redactPii: true,
      redactPiiPolicies: ["person_name", "phone_number", "email_address"],
      redactPiiSub: "entity_name",
    });
    ```
  </Tab>
</Tabs>

### Example output

With `entity_name` substitution:

```plain theme={null}
Hi, my name is [PERSON_NAME] and you can reach me at [PHONE_NUMBER] or [EMAIL_ADDRESS].
```

With `hash` substitution:

```plain theme={null}
Hi, my name is #### and you can reach me at ###-###-#### or ####@#####.###.
```

## Supported PII policies

Streaming PII redaction supports the same policies as pre-recorded PII redaction, including `person_name`, `phone_number`, `email_address`, `credit_card_number`, `us_social_security_number`, `date_of_birth`, and more.

For the full list of available policies, see [PII policies](/guardrails/redact-pii-from-transcripts#pii-policies).

## Troubleshooting

<Accordion title="Why am I still seeing PII in the transcript?" theme="dark" iconColor="white">
  PII redaction only applies to **final turns**. If you're seeing PII, you
  likely set `include_partial_turns` to `true`, which returns unredacted
  partial turns alongside redacted finals. Remove that override (or set it to
  `false`) to only receive redacted final turns — this is the default when
  `redact_pii` is enabled.
</Accordion>

<Accordion title="Can I redact PII from the audio itself?" theme="dark" iconColor="white">
  Audio redaction is not available for streaming. To generate a redacted audio
  file, use [pre-recorded PII redaction](/guardrails/redact-pii-from-transcripts#create-redacted-audio-files)
  with the `redact_pii_audio` parameter.
</Accordion>
