> This page is for version v0.24.1.
> For other versions, use one of these documentation indexes:
> - Latest (default): https://docs.nvidia.com/nemo/guardrails/latest/llms.txt
> - v0.24.1: https://docs.nvidia.com/nemo/guardrails/v0.24.1/llms.txt
> - v0.24.0: https://docs.nvidia.com/nemo/guardrails/v0.24.0/llms.txt
> - v0.23.0: https://docs.nvidia.com/nemo/guardrails/v0.23.0/llms.txt
> - v0.22.0: https://docs.nvidia.com/nemo/guardrails/v0.22.0/llms.txt

> 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 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                                        |
| -------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| [`_mask_pii_outcome`](#nemoguardrails-library-privateai-actions-_mask_pii_outcome)           | -                                                  |
| [`_pii_detection_outcome`](#nemoguardrails-library-privateai-actions-_pii_detection_outcome) | -                                                  |
| [`detect_pii`](#nemoguardrails-library-privateai-actions-detect_pii)                         | Checks whether the provided text contains any 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._mask_pii_outcome(
    source: str,
    original_text: str,
    masked_text: str
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

```python
nemoguardrails.library.privateai.actions._pii_detection_outcome(
    has_pii: bool
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

```python
nemoguardrails.library.privateai.actions.detect_pii(
    source: str,
    text: str,
    config: nemoguardrails.RailsConfig,
    http_client: nemoguardrails.http.HTTPClient | None = None,
    kwargs = {}
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

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
RailOutcome.block() if PII is detected, RailOutcome.allow() otherwise.

**Raises:**

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

```python
nemoguardrails.library.privateai.actions.mask_pii(
    source: str,
    text: str,
    config: nemoguardrails.RailsConfig,
    http_client: nemoguardrails.http.HTTPClient | None = None
) -> nemoguardrails.actions.rail_outcome.RailOutcome
```

async

Masks any detected PII in the provided text.

**Parameters:**

**`source`** `str`

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

---

**`text`** `str`

The text to check.

---

**`config`** `RailsConfig`

The rails configuration object.

---

**Returns:** `RailOutcome`

RailOutcome.transform() with the altered text if it changed, RailOutcome.allow() otherwise.

**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__)
```