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

# PII SDK Reference

> Detect, redact, and restore PII in text with the Node.js and Python SDKs to keep personally identifiable information out of your LLM requests.

## PII

### Get PII Capabilities

Reports the entity catalog, supported regions, and default thresholds the PII detection service currently exposes, including per-entity default thresholds.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.pii.capabilities()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.pii.capabilities();

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "languages": List[str],  # optional
        "base_entities": List[str],  # optional
        "all_entities": List[str],  # optional
        "regions": List[str],  # optional
        "region_entities": {  # optional
            "entities": List[str],  # optional
        },
        "entity_thresholds": Dict[str, float],  # optional
        "default_threshold": Optional[float],
        "max_text_chars": Optional[int],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      languages?: string[];
      baseEntities?: string[];
      allEntities?: string[];
      regions?: string[];
      regionEntities?: {
        entities?: string[];
      };
      entityThresholds?: Record<string, number>;
      defaultThreshold?: number;
      maxTextChars?: number;
    }
    ```
  </CodeGroup>
</Expandable>

### Detect PII

Reports whether the supplied text contains personally identifiable information, optionally with a per-type entity breakdown.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.pii.detect()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.pii.detect({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "text": Optional[str],
        "language": Optional[str],
        "threshold": Optional[float],
        "include_entities": Optional[bool],
        "regions": List[str],  # optional
        "entities": List[str],  # optional
        "entity_thresholds": Dict[str, float],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      text?: string;
      language?: string;
      threshold?: number;
      includeEntities?: boolean;
      regions?: string[];
      entities?: string[];
      entityThresholds?: Record<string, number>;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "has_pii": Optional[bool],
        "entities": Dict[str, int],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      hasPii?: boolean;
      entities?: Record<string, number>;
    }
    ```
  </CodeGroup>
</Expandable>

### Redact PII

Replaces detected PII with placeholders and returns the reverse mapping needed to restore the original text.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.pii.redact()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.pii.redact({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "text": Optional[str],
        "language": Optional[str],
        "threshold": Optional[float],
        "regions": List[str],  # optional
        "entities": List[str],  # optional
        "entity_thresholds": Dict[str, float],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      text?: string;
      language?: string;
      threshold?: number;
      regions?: string[];
      entities?: string[];
      entityThresholds?: Record<string, number>;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "redacted_text": Optional[str],
        "mappings": Dict[str, str],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      redactedText?: string;
      mappings?: Record<string, string>;
    }
    ```
  </CodeGroup>
</Expandable>

### Restore PII

Reverses a redaction, substituting placeholders back to their original values using the mapping returned by Redact.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from orq_ai_sdk import Orq
  import os

  with Orq(
      api_key=os.getenv("ORQ_API_KEY", ""),
  ) as orq:

      res = orq.pii.restore()

      # Handle response
      print(res)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import { Orq } from "@orq-ai/node";

  const orq = new Orq({
    apiKey: process.env["ORQ_API_KEY"] ?? "",
  });

  async function run() {
    const result = await orq.pii.restore({});

    console.log(result);
  }

  run();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "redacted_text": Optional[str],
        "mappings": Dict[str, str],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      redactedText?: string;
      mappings?: Record<string, string>;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "original_text": Optional[str],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      originalText?: string;
    }
    ```
  </CodeGroup>
</Expandable>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.