For the complete documentation index, see llms.txt. This page is also available as Markdown.

Service installation and deployment

1. Installation and deployment

The service is dockerized, and there is a Docker image in a Facephi repository. To download the image, you must log in as follows:

docker login facephicorp.jfrog.io
user: username
pass: token

Download the image:

docker pull facephicorp.jfrog.io/docker-pro-fphi/facephi-ocr-service:#VERSION#

Where #VERSION# is the version number we want to download (e.g. 6.8.2).

2. docker-compose

One way to deploy the service is to create a file docker-compose.yml with the following content:

version: '3.7'

services:
  ocr-service:
    image: facephicorp.jfrog.io/docker-pro-fphi/facephi-ocr-service:#VERSION#
    container_name: facephi-ocr-service
    ports:
      - "6982:6982"
    environment:
      # Optional JWT protection
      # - FACEPHI_OCR_REST_AUTH_ENABLED=true
      # - FACEPHI_OCR_REST_AUTH_JWT_SECRET=shared-secret
      # - FACEPHI_OCR_REST_AUTH_ACCEPT_AUTHORIZATION_HEADER=true
      # - FACEPHI_OCR_REST_AUTH_ACCEPT_API_KEY_HEADER=false
      # - FACEPHI_OCR_REST_AUTH_API_KEY_HEADER_NAME=x-api-key
    volumes:
      - ~/facephi_ocr_license:/service/license
      - ~/facephi_ocr_configuration:/service/config
      - ~/facephi_ocr_logs:/service/logs
      - ~/facephi_ocr_custom_templates:/service/custom_templates

Note the volume that is mounted in the container. This volume is used to store the license file. The volume facephi_ocr_configuration is optional, but allows you to configure the service. See section 2.2 Service. The volume facephi_ocr_logs is optional, but allows logs to be saved in local storage, preventing them from being lost when the Docker container stops. The volume facephi_ocr_custom_templates is optional, but allows custom document templates to be added. You can copy your custom templates into this folder and then configure the service to use them. See section 3.2 Service.

Run the following command, inside the folder where the docker-compose.yml file is located, to deploy the service:

3. License configuration

To use this service, you need to have a valid license file.

The license file could contain the following information:

The license file can be passed as a parameter to the service. By default, the service will look for a file called /service/license/license.lic. In the case of the Docker container, the configuration file could be located in a volume mounted at /service/license.

To connect to our license servers, you must add the following rules to your firewall rules:

IP
Port
Type

52.223.22.71

443

TCP/IP

35.71.188.31

443

TCP/IP

75.2.113.112

443

TCP/IP

99.83.149.57

443

TCP/IP

Then, add the following URLs to your whitelist:

4. Service configuration

The configuration file could contain the following default information:

The configuration file can be passed as a parameter to the service. By default, the service will look for a file called /service/config/config.json. In the case of the Docker container, the configuration file could be located in a volume mounted at /service/config.

All parameters are optional. If any parameter is not present, the default value will be used instead.

JWT authentication is optional and disabled by default. The startup settings above can also be provided using environment variables with the prefix FACEPHI_OCR_REST_AUTH_:

  • FACEPHI_OCR_REST_AUTH_ENABLED

  • FACEPHI_OCR_REST_AUTH_JWT_SECRET

  • FACEPHI_OCR_REST_AUTH_ACCEPT_AUTHORIZATION_HEADER

  • FACEPHI_OCR_REST_AUTH_ACCEPT_API_KEY_HEADER

  • FACEPHI_OCR_REST_AUTH_API_KEY_HEADER_NAME

When JWT is enabled, GET /api/v1/version and GET /api/v1/health remain public. The rest of the endpoints require a valid JWT via Authorization: Bearer <jwt> or the configured API Key header.

The JWT startup settings are only applied when the service starts. GET /api/v1/config does not expose these fields and POST /api/v1/config rejects attempts to modify them.

4.1. document_interpreter_version

There are two different interpreters available for processing identity documents and foreigner documents.

These interpreters differ in the following aspects:

  • Supported countries

  • Output format

  • Available fields

Supported countries

Version 1:

  • Argentina (ARG)

  • Mexico (MEX)

Version 2 officially supports a wider set of countries, including:

  • Argentina (ARG)

  • Bolivia (BOL)

  • Brazil (BRA)

  • Canada (CAN)

  • Chile (CHL)

  • Colombia (COL)

  • Costa Rica (CRI)

  • Dominican Republic (DOM)

  • Ecuador (ECU)

  • El Salvador (SLV)

  • Guatemala (GTM)

  • Honduras (HND)

  • Jordan (JOR)

  • Mexico (MEX)

  • Nicaragua (NIC)

  • Nigeria (NGA)

  • Panama (PAN)

  • Paraguay (PRY): PRY I v3, PRY I v2

  • Peru (PER): PER I v5, PER I v2

  • South Africa (ZAF)

  • South Korea (KOR)

  • Spain (ESP)

  • Uganda (UGA)

  • Uruguay (URY)

  • Vietnam (VNM)

Output format

Each version structures its output data differently.

Version 1 organizes the extracted data using the keys front and back to distinguish between the front and back of the document:

Version 2, on the other hand, uses a nested structure under the key reader, with numeric identifiers to represent each side of the document (0 for the front and 1 for the back), along with more detailed path-type keys:

Version 2 also supports universal output (document_interpreter_use_universal=1)

Available fields

In addition to variations in the data structure, there may be differences in the fields themselves. Some fields may exist only in one format and, even if a field appears in all formats, its content may change.

Last updated