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

# Process Files Base64

> Detect entities such as PII, PHI or PCI in a base64-encoded file using Private AI's entity detection engine. After entity detection, a copy of the file with all entities removed is created and returned.

This route is similar to `/v3/process/files/uri`, but passes the file in the POST request itself. This route allows for simple setup and testing, as no folders or volumes need to be mounted to the container.

This route supports the following content types: application/dicom, application/json, application/msword, application/pdf, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/vnd.openxmlformats-officedocument.presentationml.presentation, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/xml, audio/m4a, audio/mp3, audio/mp4, audio/mp4a-latm, audio/mpeg, audio/wav, audio/webm, audio/x-wav, image/bmp, image/jpeg, image/jpg, image/png, image/tif, image/tiff, image/x-ms-bmp, message/rfc822, text/csv, text/plain



## OpenAPI

````yaml /openapi/privateai_3.8.2.json post /v3/process/files/base64
openapi: 3.1.0
info:
  title: API Reference
  description: Private AI API Reference
  termsOfService: https://www.private-ai.com/terms-of-use/
  contact:
    url: https://www.private-ai.com/contact/
    email: info@private-ai.com
  version: 3.8.2
servers:
  - url: https://api.private-ai.com/deid
    description: Private AI Community API
  - url: https://api.private-ai.com/cloud
    description: Private AI Cloud API
  - url: http://localhost:8080
    description: Local Server
security: []
paths:
  /v3/process/files/base64:
    post:
      summary: Process Files Base64
      description: >-
        Detect entities such as PII, PHI or PCI in a base64-encoded file using
        Private AI's entity detection engine. After entity detection, a copy of
        the file with all entities removed is created and returned.


        This route is similar to `/v3/process/files/uri`, but passes the file in
        the POST request itself. This route allows for simple setup and testing,
        as no folders or volumes need to be mounted to the container.


        This route supports the following content types: application/dicom,
        application/json, application/msword, application/pdf,
        application/vnd.ms-excel, application/vnd.ms-powerpoint,
        application/vnd.openxmlformats-officedocument.presentationml.presentation,
        application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
        application/vnd.openxmlformats-officedocument.wordprocessingml.document,
        application/xml, audio/m4a, audio/mp3, audio/mp4, audio/mp4a-latm,
        audio/mpeg, audio/wav, audio/webm, audio/x-wav, image/bmp, image/jpeg,
        image/jpg, image/png, image/tif, image/tiff, image/x-ms-bmp,
        message/rfc822, text/csv, text/plain
      operationId: process_files_base64_v3_process_files_base64_post
      parameters:
        - name: x-api-key
          in: header
          required: false
          schema:
            type: string
            default: ''
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessFileRequestBase64'
            examples:
              process_file:
                summary: Process File with base64-encoded payload
                value:
                  file:
                    data: >-
                      JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...
                    content_type: application/pdf or image/jpeg
                  entity_detection:
                    return_entity: true
                  pdf_options:
                    density: 150
                    max_resolution: 2000
                  audio_options:
                    bleep_start_padding: 0
                    bleep_end_padding: 0
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessFileResponseBase64'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ProcessFileRequestBase64:
      properties:
        file:
          allOf:
            - $ref: '#/components/schemas/File'
          description: >-
            This section contains a set of parameters to control the PII
            detection process. All fields have sensible default that can be
            changed for specific needs.
        entity_detection:
          allOf:
            - $ref: '#/components/schemas/PIIDetectionParams'
          description: >-
            This section contains a set of parameters to control the PII
            detection process. All fields have sensible default that can be
            changed for specific needs.
        pdf_options:
          allOf:
            - $ref: '#/components/schemas/PDFOptions'
          description: >-
            Options to process PDF files, such as the rendering quality when
            each page is turned into an image.
        image_options:
          allOf:
            - $ref: '#/components/schemas/ImageOptions'
          description: Options to process image files, such as the masking mode.
        audio_options:
          allOf:
            - $ref: '#/components/schemas/AudioOptions'
          description: >-
            Options to process audio files, such as the padding to add while
            redacting audio segments.
        project_id:
          anyOf:
            - type: string
              maxLength: 60
              pattern: ^[a-zA-Z0-9\-_\:]*$
            - type: 'null'
          title: Project Id
          description: >-
            Used to categorize requests for reporting purposes. Limited to
            alphanumeric characters or the following special characters :_-
      additionalProperties: false
      type: object
      required:
        - file
      title: ProcessFileRequestBase64
    ProcessFileResponseBase64:
      properties:
        processed_file:
          type: string
          title: Processed File
          description: the base64 encoded file content of the redacted file.
        processed_text:
          type: string
          title: Processed Text
          description: >-
            This field contains the redacted version of any text that was
            extracted from the input file. It corresponds to a redacted ASR
            transcript for audio files and any text found inside a document such
            as a PDF or image file.
        entities:
          items:
            $ref: '#/components/schemas/FileEntityItem'
          type: array
          title: Entities
          description: A list of all entities found in the provided file.
        entities_present:
          type: boolean
          title: Entities Present
          description: Returns `True` if the list of detected entities is not empty.
        languages_detected:
          additionalProperties:
            type: number
          type: object
          title: Languages Detected
          description: >-
            A dictionary containing ISO 639-1 language labels and the likelihood
            of their detection in the request payload.
      type: object
      required:
        - processed_file
        - processed_text
        - entities
        - entities_present
        - languages_detected
      title: ProcessFileResponseBase64
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    File:
      properties:
        data:
          type: string
          title: Data
          description: Base64 encoded ASCII text data of the file to process.
        content_type:
          type: string
          title: Content Type
          description: >-
            Content type of the file. Currently ['application/dicom',
            'application/json', 'application/msword', 'application/pdf',
            'application/vnd.ms-excel', 'application/vnd.ms-powerpoint',
            'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            'application/xml', 'audio/m4a', 'audio/mp3', 'audio/mp4',
            'audio/mp4a-latm', 'audio/mpeg', 'audio/wav', 'audio/webm',
            'audio/x-wav', 'image/bmp', 'image/jpeg', 'image/jpg', 'image/png',
            'image/tif', 'image/tiff', 'image/x-ms-bmp', 'message/rfc822',
            'text/csv', 'text/plain'] are supported.
      additionalProperties: false
      type: object
      required:
        - data
        - content_type
      title: File
    PIIDetectionParams:
      properties:
        accuracy:
          allOf:
            - $ref: '#/components/schemas/AccuracyMode'
          description: >-
            Selects the model used to identify PII in the input text. By
            default, the `high_automatic` accuracy model is used. This default
            automatically chooses either the high or high_multilingual model.
            While the models used by the Private AI solution are highly
            optimized (~25X faster than a reference transformer implementation),
            in high-throughput cases it is possible to trade accuracy for speed
            by selecting either the `standard` or `standard_high` accuracy
            modes. Multilingual support can be enabled by using one of the
            multilingual models, namely `standard_high_multilingual` (GPU
            container only) and `high_multilingual`. The multilingual models
            process all supported languages including English, without the need
            to specify language. It is advisable to use the English-only models
            where possible, as they perform slightly better on English.
            Automatic Models can determine which model to use (English or
            Multilingual) depending on the languages detected, provided
            Multilingual models are available.
        entity_types:
          items:
            anyOf:
              - $ref: '#/components/schemas/EnableEntityTypeSelector'
              - $ref: '#/components/schemas/DisableEntityTypeSelector'
          type: array
          title: Entity Types
          description: >-
            Controls which entity types and legislation sets are detected. See
            [Supported Entity
            Types](https://docs.private-ai.com/entities/#supported-entities) for
            the list of possible entities and legislation sets. By default, all
            entities are detected and removed. You can specify one of many
            selectors, which can be either an individual entity type such as
            `LOCATION_CITY` or a legislation like `GDPR`.
            `EnableEntityTypeSelector` selectors will add entity types to
            detect. On the contrary, `DisableEntityTypeSelector` selectors will
            ignore entities of the specified types. If only
            `DisableEntityTypeSelector` selectors are specified, they are
            assumed to be ignoring entity types from the entire supported list
            of entity types.
        filter:
          items:
            anyOf:
              - $ref: '#/components/schemas/AllowFilter'
              - $ref: '#/components/schemas/BlockFilter'
              - $ref: '#/components/schemas/AllowTextFilter'
          type: array
          title: Filter
          description: >-
            This field contains a list of filters expressed as regular
            expressions. These regular expressions can help users customize PII
            detection in a few ways. `ALLOW` filters can disabled redaction of
            entities containing specific text (e.g. a document id with format
            ID-1212 that is not sensitive). On the other hand, the `BLOCK`
            filters can augment the existing set of entities with custom
            entities (e.g. detecting sensitive medical code with format A18.32
            as IDC_NUMBER). Finally, the `ALLOW_TEXT` filters can select a
            section of text in a document that should not be redacted (e.g.
            author names in scientific references or dates in an audit trail
            log).
        return_entity:
          type: boolean
          title: Return Entity
          description: >-
            Controls whether the PII list in the response contains the `text`
            field. Turning this off means that no sensitive PII is returned in
            the response.
          default: true
        enable_non_max_suppression:
          type: boolean
          title: Enable Non Max Suppression
          description: >-
            When set, if the best label of an entity is disabled then the entity
            will not be redacted. This could be useful to minimize
            false-positives when disabling an entity label like `ACCOUNT_NUMBER`
            that is closely related to another entity like `BANK_ACCOUNT`. Note
            that, the effect of that flag is difficult to predict when disabling
            labels like `LOCATION_COUNTRY` or `NAME_GIVEN` that are hierarchical
            by nature (i.e. a `NAME_GIVEN` entity is also a `NAME` entity). We
            don't recommend setting that flag to true when some of these
            hierarchical entities are disabled.
          default: false
      additionalProperties: false
      type: object
      title: PIIDetectionParams
    PDFOptions:
      properties:
        density:
          type: integer
          title: Density
          description: >-
            PDFs are converted into images using this DPI value. Smaller values
            result in images with smaller resolutions, which will take up less
            storage space and process faster, at the cost of output quality &
            redaction accuracy.
          default: 200
        max_resolution:
          type: integer
          title: Max Resolution
          description: >-
            PDFs are converted into images using the `density` DPI value. Any
            resulting images with maximum size length larger than this will be
            resized to this value, while preserving aspect ratio.
          default: 3000
        enable_pdf_text_layer:
          type: boolean
          title: Enable Pdf Text Layer
          description: >-
            This PDF option controls whether a text layer is included in the PDF
            files generated by         the process. When set to `true`, the
            application will include a text layer in the PDFs, allowing for
            text         selection, search, and accessibility features. If set
            to any other value or not set at all, the text layer         will be
            disabled, potentially resulting in smaller file sizes, faster
            processing, but with reduced         functionality regarding text
            selection and search. The default value is `True`, but can be
            adjusted via `PAI_ENABLE_PDF_TEXT_LAYER` environment variable by
            setting it to `False`
          default: true
      additionalProperties: false
      type: object
      title: PDFOptions
    ImageOptions:
      properties:
        masking_method:
          allOf:
            - $ref: '#/components/schemas/MaskMode'
          description: >-
            Masking Mode for Image Deidentification. Available options are
            ['blur', 'blackbox']
          default: blur
      additionalProperties: false
      type: object
      title: ImageOptions
    AudioOptions:
      properties:
        bleep_start_padding:
          type: number
          minimum: 0
          title: Bleep Start Padding
          description: Additional padding at the start of bleep, in seconds.
          default: 0.5
        bleep_end_padding:
          type: number
          minimum: 0
          title: Bleep End Padding
          description: Additional padding at the end of bleep, in seconds.
          default: 0.2
        distortion_steps:
          type: integer
          title: Distortion Steps
          description: >-
            Specifies how the distortion will be made. Providing a number more
            than 0 will result in a higher tone and a coefficient less than 0
            will result in a lower tone.
          default: 0
        bleep_frequency:
          type: integer
          title: Bleep Frequency
          description: >-
            The `bleep_frequency` parameter configures the frequency of the sine
            wave used for the bleep sound in an audio segment.         This
            setting allows users to adjust the pitch of the bleep, with higher
            values resulting in a higher pitch and vice versa. Ideal for        
            customizing the bleep tone to suit various audio environments, it is
            expressed in Hertz (Hz) and should be chosen considering the
            balance         and clarity needed in the audio. The default setting
            is 600 Hz, which represents a standard bleep tone.
          default: 600
        bleep_gain:
          type: number
          title: Bleep Gain
          description: >-
            The `bleep_gain` parameter sets the gain level, in decibels (dB),
            for the bleep sound within the audio segment.         It controls
            the relative loudness of the bleep, allowing for precise volume
            adjustments. A value of 0.0 dB maintains the         original
            amplitude of the bleep, positive values increase its loudness, and
            negative values decrease it.
          default: -3
      additionalProperties: false
      type: object
      title: AudioOptions
    FileEntityItem:
      properties:
        processed_text:
          type: string
          title: Processed Text
          description: >-
            The corresponding marker in the de-identified text (result field),
            where the entity exists. Note that this field is only populated for
            text-based formats such as `.txt`
        text:
          type: string
          title: Text
          description: >-
            The text corresponding to the entity. For images the text is
            obtained using OCR, while for audio the text is obtained using ASR.
        location:
          anyOf:
            - $ref: '#/components/schemas/TextLocation'
            - $ref: '#/components/schemas/ImageLocation'
            - $ref: '#/components/schemas/AudioLocation'
          title: Location
        best_label:
          type: string
          title: Best Label
          description: The entity label with the highest likelihood.
        labels:
          additionalProperties:
            type: number
          type: object
          title: Labels
          description: >-
            A dictionary of all possible labels, together with associated
            likelihoods. Note that these are not strictly probabilities and do
            not sum to 1, as a word can belong to multiple classes. The scores
            have also been thresholded, so no additional thresholding is
            necessary.
      type: object
      required:
        - processed_text
        - text
        - location
        - best_label
        - labels
      title: FileEntityItem
      description: Empty
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    AccuracyMode:
      type: string
      enum:
        - standard
        - standard_high
        - standard_high_multilingual
        - standard_high_automatic
        - high
        - high_multilingual
        - high_automatic
      title: AccuracyMode
      description: >-
        Selects the model used to identify PII in the input text. By default,
        the "high_automatic" accuracy model is used. This default automatically
        chooses either the high or high_multilingual model. While the models
        used by the Private AI solution are highly optimized (~25X faster than a
        reference transformer implementation), in high-throughput cases it is
        possible to trade accuracy for speed by selecting either the "standard"
        or "standard_high" accuracy modes. Multilingual support can be enabled
        by using one of the multilingual models, namely
        "standard_high_multilingual" (GPU container only) and
        "standard_high_multilingual". The multilingual models process all
        supported languages including English, without the need to specify
        language. It is advisable to use the English-only models where possible,
        as they perform slightly better on English. Automatic Models can
        determine which model to use (English or Multilingual) depending on the
        languages detected, provided Multilingual models are available.
    EnableEntityTypeSelector:
      properties:
        type:
          const: ENABLE
          title: Type
          default: ENABLE
        value:
          items:
            type: string
          type: array
          title: Value
          description: >-
            A list of entity types to detect and remove. See [Supported Entity
            Types](https://docs.private-ai.com/entities/#supported-entities) for
            a complete list of entity types. This can also be one or many
            legislations. We currently support these legislations  ['APPI',
            'APPI_SENSITIVE', 'CPRA', 'GDPR', 'GDPR_SENSITIVE', 'HIPAA', 'LIDI',
            'PCI', 'PHI', 'QUEBEC_PRIVACY_ACT', 'CORE_ENTITIES',
            'NUMERICAL_EXCL_PCI'].
      additionalProperties: false
      type: object
      title: EnableEntityTypeSelector
    DisableEntityTypeSelector:
      properties:
        type:
          const: DISABLE
          title: Type
          default: DISABLE
        value:
          items:
            type: string
          type: array
          title: Value
          description: >-
            A list of entity types to ignore. See [Supported Entity
            Types](https://docs.private-ai.com/entities/#supported-entities) for
            a complete list of entity types.
      additionalProperties: false
      type: object
      title: DisableEntityTypeSelector
    AllowFilter:
      properties:
        type:
          const: ALLOW
          title: Type
          description: >-
            Entities with text matching the provided regex pattern will be
            discarded. It is also possible to set this option via environment
            variable. See [Environment
            Variables](https://docs.private-ai.com/environment-variables).
          default: ALLOW
        pattern:
          type: string
          title: Pattern
          description: >-
            A python regex pattern (e.g. `r"^ID-[\d]{4}$"`). This pattern will
            be used to match the entity text. If it matches zero or more
            characters at the **beginning of the entity text**, the entity will
            be ignored. Be sure to use the end of string character `$` if you
            want to only allow entities when the entirety of the text matches.
            It is also important to note that regex patterns may require
            escaping when used in JSON objects.
      additionalProperties: false
      type: object
      required:
        - pattern
      title: AllowFilter
    BlockFilter:
      properties:
        type:
          const: BLOCK
          title: Type
          description: >-
            The block feature allows you to extend the functionality of the
            Private AI models by using regular expressions. This way, you can
            define a Python regex pattern that will be used to identify
            additional tokens with the given PII label.


            Several block list filters can be specified with their own regex
            pattern.


            Lastly,for supported labels, if you would like the model to pick up
            only the tokens from the block list, you can use the enabled entity
            type feature together with the block list feature. This can be done
            by defining a list of enabled entity types and not including the
            supported label you are adding to the block list. For example, if
            you would like the label `ORGANIZATION` to only pick up Microsoft,
            you can define the enabled entity types as `[{"type":"ENABLE",
            "value": "NAME"}, {"type": "ENABLE", "value": "LOCATION"}, {"type":
            "ENABLE", "value": "AGE"}, ...]` (and omitting `ORGANIZATION`) and
            the block list as `[{"type": "BLOCK", "entitiy_type":
            "ORGANIZATION", "pattern": "Microsoft"}]`.
          default: BLOCK
        entity_type:
          type: string
          title: Entity Type
          description: >-
            Name of the custom entity type. It can either be a completely new
            entity type such as `CUSTOM_ID` or an existing entity, such as
            `NAME`.
        pattern:
          type: string
          title: Pattern
          description: >-
            This is a pattern to match in the text. This feature uses regex
            patterns, you can either pass a word (e.g. the, word, custom, etc.)
            or you can pass a valid Python regex pattern. It is important to
            note that regex patterns may require escaping when used in JSON
            objects. To give an example, if you would like to send the regex
            pattern `r"\b\w{4}\b"` which will catch every 4-character word, you
            need to send it as `"\\b\\w{4}\\b"`. A complete JSON grammar is
            found here: https://www.json.org/json-en.html. More information on
            how to write a python regex is found here:
            https://docs.python.org/3/library/re.html


            It is important to note also that only non-overlapping matches are
            returned.
        threshold:
          type: number
          title: Threshold
          description: >-
            This is defining a likelihood threshold for custom entity. This
            likelihood is compared against the predicted model likelihood and if
            it is greater then the custom entity is outputted instead of the
            model predicted entity. By default this threshold is set to 1.0
            which will ensure that the blocked entities will always be preferred
            over a matching model predicted entity. This can be any value
            between 0 and 1.
          default: 1
      additionalProperties: false
      type: object
      required:
        - entity_type
        - pattern
      title: BlockFilter
    AllowTextFilter:
      properties:
        type:
          const: ALLOW_TEXT
          title: Type
          description: >-
            Input text matching the provided regex pattern will not be redacted.
            It is currently not possible to set this option via environment
            variable.
          default: ALLOW_TEXT
        pattern:
          type: string
          title: Pattern
          description: >-
            A python regex pattern (e.g. `r"^ID-[\d]{4}$"`). This pattern will
            be used to match the input text. Entities detected **inside the
            matched text** will be ignored. Note that capturing groups can be
            used in the regex pattern. If present, only the text matching a
            capturing group will be left unredacted. It is also important to
            note that regex patterns may require escaping when used in JSON
            objects.
      additionalProperties: false
      type: object
      required:
        - pattern
      title: AllowTextFilter
    MaskMode:
      type: string
      enum:
        - blur
        - blackbox
      title: MaskMode
    TextLocation:
      properties:
        stt_idx:
          type: integer
          title: Stt Idx
          description: Start character index of the entity in the original text.
        end_idx:
          type: integer
          title: End Idx
          description: >-
            Index of the character immediately following the entity, such that
            end_idx - stt_idx = number of characters in the entity.
        stt_idx_processed:
          type: integer
          title: Stt Idx Processed
          description: Start character index of the entity in the processed text.
        end_idx_processed:
          type: integer
          title: End Idx Processed
          description: >-
            Index of the character immediately following the entity in the
            processed text.
      type: object
      required:
        - stt_idx
        - end_idx
        - stt_idx_processed
        - end_idx_processed
      title: TextLocation
      description: >-
        Start and end indices of the entity in a text-based file format such as
        `.txt`.
    ImageLocation:
      properties:
        page:
          type: integer
          title: Page
          description: >-
            The page or layer that the entity occurs on. This corresponds to
            page in a PDF document or layer in a TIFF image.
        x0:
          type: number
          title: X0
          description: X coordinate of the upper left point of the entity bounding box.
        x1:
          type: number
          title: X1
          description: X coordinate of the lower right point of the entity bounding box.
        y0:
          type: number
          title: Y0
          description: Y coordinate of the upper left point of the entity bounding box.
        y1:
          type: number
          title: Y1
          description: Y coordinate of the lower right point of the entity bounding box.
      type: object
      required:
        - page
        - x0
        - x1
        - y0
        - y1
      title: ImageLocation
      description: >-
        Bounding box of the entity in an image or PDF file (PDF files are
        converted to images). The origin is the upper left pixel of the image.
        Coordinates are given as a fraction of the X and Y image dimensions.
    AudioLocation:
      properties:
        stt_time:
          type: number
          title: Stt Time
          description: The start timestamp of the entity, in seconds
        end_time:
          type: number
          title: End Time
          description: The end timestamp of the entity, in seconds
      type: object
      required:
        - stt_time
        - end_time
      title: AudioLocation
      description: Timestamp of the entity in an audio file such as `.wav`.

````