> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/guardrails/llms.txt.
> For full documentation content, see https://docs.nvidia.com/nemo/guardrails/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/guardrails/_mcp/server.

# nemoguardrails.library.privateai.actions

PII detection using Private AI.

## Module Contents

### Functions

| Name                                                                                 | Description                                        |
| ------------------------------------------------------------------------------------ | -------------------------------------------------- |
| [`detect_pii`](#nemoguardrails-library-privateai-actions-detect_pii)                 | Checks whether the provided text contains any PII. |
| [`detect_pii_mapping`](#nemoguardrails-library-privateai-actions-detect_pii_mapping) | Mapping for detect\_pii.                           |
| [`mask_pii`](#nemoguardrails-library-privateai-actions-mask_pii)                     | Masks any detected PII in the provided text.       |

### Data

[`log`](#nemoguardrails-library-privateai-actions-log)

### API

```python
nemoguardrails.library.privateai.actions.detect_pii(
    source: str,
    text: str,
    config: nemoguardrails.RailsConfig,
    kwargs = {}
)
```

async

Checks whether the provided text contains any PII.

Args
source: The source for the text, i.e. "input", "output", "retrieval".
text: The text to check.
config: The rails configuration object.

Returns
True if PII is detected, False otherwise.

**Raises:**

* `ValueError`: If PAI\_API\_KEY is missing when using cloud API or if the response is invalid.

```python
nemoguardrails.library.privateai.actions.detect_pii_mapping(
    result: bool
) -> bool
```

Mapping for detect\_pii.

Since the function returns True when PII is detected,
we block if result is True.

```python
nemoguardrails.library.privateai.actions.mask_pii(
    source: str,
    text: str,
    config: nemoguardrails.RailsConfig
)
```

async

Masks any detected PII in the provided text.

**Parameters:**

The source for the text, i.e. "input", "output", "retrieval".

The text to check.

The rails configuration object.

**Returns:**

The altered text with PII masked.

**Raises:**

* `ValueError`: If PAI\_API\_KEY is missing when using cloud API or if the response is invalid.

```python
nemoguardrails.library.privateai.actions.log = logging.getLogger(__name__)
```