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

# Presidio PII Detection

> Detects personally identifiable information in text, including phone numbers, email addresses, and
social security numbers. It allows customization of the detection threshold and the specific types of PII to check.



## OpenAPI

````yaml post /presidio/pii_detection/evaluate
openapi: 3.1.0
info:
  title: LangEvals API
  version: 1.0.0
  description: API for LangEvals evaluators
servers:
  - url: https://app.langwatch.ai/api/evaluations
    description: Production server
security:
  - api_key: []
paths:
  /presidio/pii_detection/evaluate:
    post:
      summary: Presidio PII Detection
      description: >-
        Detects personally identifiable information in text, including phone
        numbers, email addresses, and

        social security numbers. It allows customization of the detection
        threshold and the specific types of PII to check.
      operationId: presidio_pii_detection_evaluate
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/presidio_pii_detectionRequest'
                - type: object
                  properties:
                    settings:
                      $ref: '#/components/schemas/presidio_pii_detectionSettings'
        required: true
      responses:
        '200':
          description: Successful evaluation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/EvaluationResult'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
      x-codeSamples:
        - lang: python
          label: Experiment
          source: |
            import langwatch

            df = langwatch.datasets.get_dataset("dataset-id").to_pandas()

            experiment = langwatch.experiment.init("my-experiment")

            for index, row in experiment.loop(df.iterrows()):
                # your execution code here
                experiment.evaluate(
                    "presidio/pii_detection",
                    index=index,
                    data={
                        "input": row["input"],
                        "output": output,
                    },
                    settings={}
                )
        - lang: python
          label: Online Evaluation
          source: |-
            import langwatch

            @langwatch.span()
            def my_llm_step():
                ... # your existing code
                result = langwatch.evaluation.evaluate(
                    "presidio/pii_detection",
                    name="My Presidio PII Detection Check",
                    data={
                        "input": "",
                        "output": "",
                    },
                    settings={},
                )
                print(result)
        - lang: typescript
          label: Experiment
          source: >-
            import { LangWatch } from "langwatch";


            const langwatch = new LangWatch();


            // Fetch dataset from LangWatch

            const dataset = await langwatch.datasets.get("your-dataset-slug");


            const experiment = await
            langwatch.experiments.init("my-experiment");


            await experiment.run(
              dataset.entries.map((e) => e.entry),
              async ({ item, index }) => {
                // Run your LLM/agent
                const output = await myLLM(item.input);

                // Evaluate the output
                await experiment.evaluate("presidio/pii_detection", {
                  index,
                  data: {
                    input: item.input,
                    output: output,
                  },
                });
              },
              { concurrency: 4 }
            );
        - lang: typescript
          label: Online Evaluation
          source: |-
            import { LangWatch } from "langwatch";

            const langwatch = new LangWatch();

            async function myLLMStep(input: string): Promise<string> {
              // ... your existing code

              // Call the evaluator
              const result = await langwatch.evaluations.evaluate("presidio/pii_detection", {
                name: "my-evaluation",
                data: {
                  input: "", // your input value
                  output: "", // your output value
                },
                settings: {},
              });

              console.log(result);
              return result;
            }
components:
  schemas:
    presidio_pii_detectionRequest:
      type: object
      properties:
        trace_id:
          type: string
          description: Optional trace ID to associate this evaluation with a trace
        data:
          type: object
          properties:
            input:
              type: string
              description: The input text to evaluate
            output:
              type: string
              description: The output/response text to evaluate
          required: []
      required:
        - data
    presidio_pii_detectionSettings:
      type: object
      properties:
        entities:
          description: The types of PII to check for in the input.
          type: object
          default:
            credit_card: true
            crypto: true
            email_address: true
            iban_code: true
            ip_address: true
            location: false
            person: false
            phone_number: true
            medical_license: true
            us_bank_number: false
            us_driver_license: false
            us_itin: false
            us_passport: false
            us_ssn: false
            uk_nhs: false
            sg_nric_fin: false
            au_abn: false
            au_acn: false
            au_tfn: false
            au_medicare: false
            in_pan: false
            in_aadhaar: false
            in_vehicle_registration: false
            in_voter: false
            in_passport: false
        min_threshold:
          description: >-
            The minimum confidence required for failing the evaluation on a PII
            match.
          type: number
          default: 0.5
    EvaluationResult:
      type: object
      properties:
        status:
          type: string
          enum:
            - processed
            - skipped
            - error
        score:
          type: number
          description: Numeric score from the evaluation
        passed:
          type: boolean
          description: Whether the evaluation passed
        label:
          type: string
          description: Label assigned by the evaluation
        details:
          type: string
          description: Additional details about the evaluation
        cost:
          type: object
          properties:
            currency:
              type: string
            amount:
              type: number
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: API key for authentication

````