> ## 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.

# Container Playground

> Container Playground: Your Limina Sandbox

The Container Playground is a containerized web application that allows the user to interact with our container without the need for writing code. Currently, this application supports PII redaction in text and files, and it can also generate sample code for the user if they choose to interact with Limina's REST API.

It aims to be a self-hosted version of the Limina Playground that is available on our [Customer Portal](https://portal.getlimina.ai/playground).

## Getting the Container Playground

The Container Playground image is hosted on the same container registry as our main container.

If you already have a customer portal account with us and have a license to deploy Limina's containers locally, then you can use the Docker credentials that are present in the portal to gain access to the Limina Container Playground image.

<img src="https://mintcdn.com/privateai/uP8oRoL-wtDIrw_2/images/product-guides/customer-portal-license.png?fit=max&auto=format&n=uP8oRoL-wtDIrw_2&q=85&s=794d478d7e64ab5823cf092e860f5293" alt="Where to find the licenses on Limina's Customer Portal" width="1495" height="473" data-path="images/product-guides/customer-portal-license.png" />

If you wish to host Limina locally, please [contact us](https://getlimina.ai/contact-us) to get a license.

If you prefer to use our Cloud API, you can get started right away by getting an API key through [our portal](https://portal.getlimina.ai).

Once you have the credentials ready, you can simply login with the following command:

```shell Docker Command theme={"theme":"poimandres"}
docker login -u <username> -p  <password> crprivateaiprod.azurecr.io
```

Once you are logged in, you can simply run the following command to download the image:

```shell Docker Command theme={"theme":"poimandres"}
docker pull crprivateaiprod.azurecr.io/container-ui:latest
```

## Setting up the Container Playground

There are various different ways to setup the Container Playground image. However, we will be focusing on 2 main ones in the guide. These 2 ways are:

1. Setting up the Container Playground as a standalone app
2. Setting up the Container Playground together with the Limina container

### 1. Setting up the Container Playground as a standalone app

This setup covers the cases where the main container is already deployed separately or the plan is to deploy the Container Playground and the Limina container separately for better scalability.

#### Container Playground running together with the main container on the same machine

In this case, we are assuming that the Container Playground will be running on the same machine as the Limina container. Currently, this configuration is the default one, so you can just simply start up the container with the following command:

```shell Docker Command theme={"theme":"poimandres"}
docker run --rm --network host -it crprivateaiprod.azurecr.io/container-ui:latest
```

You can access the app using the `http://localhost:3000` address.

This setup assumes that the Limina container is running and accessible at the `http://localhost:8080` address.

#### Container Playground running on a different machine

In this case, we are assuming that there is a Limina container deployed somewhere and the Container Playground is being set up separately to interact with it.

First, if the Limina container endpoints are not protected (i.e. no authentication required), then you can simply use the following command to set up the Container Playground:

```shell Docker Command theme={"theme":"poimandres"}
docker run \
    --rm \
    -p 3000:3000 \
    -e AUTH_URL=<the canonical URL of where the container UI is deployed> \
    -e AUTH_SCRET=openssl rand -base64 32 \ # Replace with outputted string
    -e PAI_API_TEXT_ENDPOINT=<the URL to the /process/text endpoint> \
    -e PAI_API_TEXT_NER_ENDPOINT=<the URL to the /ner/text endpoint> \
    -e PAI_API_FILE_ENDPOINT=<the URL to the /process/files/base64 endpoint> \
    -it crprivateaiprod.azurecr.io/container-ui:latest
```

Here, we are simply pointing the setup to the correct address so it can successfully communicate with the deidentification service.

However, if the deidentification service endpoints are protected, then you can set up the Container Playground in the following way:

```shell Docker Command theme={"theme":"poimandres"}
docker run \
    --rm \
    -p 3000:3000 \
    -e AUTH_URL=openssl rand -base64 32 \  # Replace with outputted string
    -e AUTH_SECRET=<the cananonical url> \
    -e PAI_API_TEXT_AUTH=1 \
    -e PAI_API_FILE_AUTH=1 \
    -e PAI_API_TEXT_NER_AUTH=1 \
    -e PAI_API_TEXT_AUTH_HEADER=<text endpoint authentication header name, e.g. "x-api-key"> \
    -e PAI_API_TEXT_NER_AUTH_HEADER=<NER endpoint authentication header name, e.g. "x-api-key"> \
    -e PAI_API_FILE_AUTH_HEADER=<file endpoint authentication header name, e.g. "x-api-key"> \
    -e PAI_API_TEXT_KEY=<ner endpoint API key> \
    -e PAI_API_TEXT_NER_KEY=<text endpoint API key> \
    -e PAI_API_FILE_KEY=<file endpoint API key> \
    -e PAI_API_TEXT_ENDPOINT=<the URL to the /process/text endpoint> \
    -e PAI_API_TEXT_NER_ENDPOINT=<the URL to the /ner/text endpoint> \
    -e PAI_API_FILE_ENDPOINT=<the URL to the /process/files/base64 endpoint> \
    -it crprivateaiprod.azurecr.io/playground:latest
```

**NOTE:** Currently, the Container Playground only supports the API key authentication where the credentials are passed in the request header.

To use the Container Playground with the Limina Community API Key, you can use the following:

```shell Docker Command theme={"theme":"poimandres"}
docker run \
    --rm \
    -p 3000:3000 \
    -e AUTH_URL=openssl rand -base64 32 \
    -e AUTH_SECRET=http://localhost:3000 \
    -e PAI_API_TEXT_AUTH=1 \
    -e PAI_API_TEXT_NER_AUTH=1 \
    -e PAI_API_FILE_AUTH=1 \
    -e PAI_API_TEXT_AUTH_HEADER=x-api-key \
    -e PAI_API_TEXT_NER_AUTH_HEADER=x-api-key \
    -e PAI_API_FILE_AUTH_HEADER=x-api-key \
    -e PAI_API_TEXT_KEY=<Community API Key> \
    -e PAI_API_TEXT_NER_AUTH_KEY=<Community API Key> \
    -e PAI_API_FILE_KEY=<Community API Key> \
    -e PAI_API_TEXT_ENDPOINT=https://api.private-ai.com/community/v4/process/text \
    -e PAI_API_TEXT_NER_ENDPOINT=https://api.private-ai.com/community/v4/ner/text \
    -e PAI_API_FILE_ENDPOINT=https://api.private-ai.com/community/v4/process/files/base64 \
    -it crprivateaiprod.azurecr.io/playground:latest
```

### 2. Setting up the Container Playground together with the Limina container

This setup covers the use case where the Container Playground is setup / deployed together with the Limina container on the same machine. It assumes that `docker compose` is used for this setup.

In this case, the most important point is to correctly set up the communication between the Container Playground and the Limina container. Following is an example `compose.yml` file that demonstrates how to achieve this:

```yaml Yaml theme={"theme":"poimandres"}
services:
  container_playground:
    container_name: container_playground
    image: crprivateaiprod.azurecr.io/playground:latest
    ports:
      - 3000:3000
    networks:
      - deid
    environment:
      - AUTH_URL=http://localhost:3000 canonical URL of the container-ui #Replace with canonical URL
      - AUTH_SECRET=openssl rand -base64 32 # Replace with outputted string
      - PAI_API_TEXT_ENDPOINT=http://deid:8080/process/text
      - PAI_API_TEXT_NER_ENDPOINT=http://deid:8080/ner/text
      - PAI_API_FILE_ENDPOINT=http://deid:8080/process/files/base64

  deid:
    container_name: deid
    image: crprivateaiprod.azurecr.io/deid:cpu # version 4.0.0 or later is required
    ports:
      - 8080:8080
    volumes:
      - </path/to/your/license/file.json>:/app/license/license.json
    networks:
      - deid

networks:
  deid:
    network_name: deid
```

One important thing to note here is the endpoints. Instead of using `localhost`, we are passing the name of the container (i.e. `deid`), which is an important step to make sure that both containers can communicate.

## Configuration Options

Currently, the Container Playground application can be configured using the following environment variables:

| Environment Variable           | Description                                                                                                                                                                                                                               |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PORT`                         | The port that the application is listening on in the container. Defaults to `3000`.                                                                                                                                                       |
| `AUTH_SECRET`                  | **Required** The string that is used for encrypting the session token                                                                                                                                                                     |
| `AUTH_URL`                     | The canonical URL of the Container UI                                                                                                                                                                                                     |
| `PAI_API_TEXT_ENDPOINT`        | The URL of the `/process/text` endpoint of the Limina container. Defaults to `http://localhost:8080/process/text`                                                                                                                         |
| `PAI_API_TEXT_NER_ENDPOINT`    | The URL of the `/ner/text` endpoint of the Limina container. Defaults to `http://localhost:8080/ner/text`                                                                                                                                 |
| `PAI_API_FILE_ENDPOINT`        | The URL of the `/process/files/base64` endpoint of the Limina container. Defaults to `http://localhost:8080/process/files/base64`.                                                                                                        |
| `PAI_API_TEXT_AUTH`            | Determines whether API authentication is required for the `/process/text` endpoint. Defaults to `0`, which means that it is turned off. If your `/process/text` endpoint requires authentication, please set this to `1`.                 |
| `PAI_API_TEXT_NER_AUTH`        | Determines whether API authentication is required for the `/ner/text` endpoint. Defaults to `0`, which means that it is turned off. If your `/ner/text` endpoint requires authentication, please set this to `1`.                         |
| `PAI_API_FILE_AUTH`            | Determines whether API authentication is required for the `/process/files/base64` endpoint. Defaults to `0`, which means that it is turned off. If your `/process/files/base64` endpoint requires authentication, please set this to `1`. |
| `PAI_API_TEXT_AUTH_HEADER`     | This is used if `PAI_API_TEXT_AUTH` is set to `1`. This is the request header that the API key is sent with.                                                                                                                              |
| `PAI_API_TEXT_NER_AUTH_HEADER` | This is used if `PAI_API_TEXT_NER_AUTH` is set to `1`. This is the request header that the API key is sent with.                                                                                                                          |
| `PAI_API_FILE_AUTH_HEADER`     | This is used if `PAI_API_FILE_AUTH` is set to `1`. This is the request header that the API key is sent with.                                                                                                                              |
| `PAI_API_TEXT_KEY`             | This is used if `PAI_API_TEXT_AUTH` is set to `1`. This is the API key that is used for the `/process/text` endpoint                                                                                                                      |
| `PAI_API_TEXT_NER_KEY`         | This is used if `PAI_API_TEXT_NER_AUTH` is set to `1`. This is the API key that is used for the `/ner/text` endpoint                                                                                                                      |
| `PAI_API_FILE_KEY`             | This is used if `PAI_API_FILE_AUTH` is set to `1`. This is the API key that is used for the `/process/files/base64` endpoint                                                                                                              |

#### Container Playground - Text Processing with Automatic Updates

If you wish to automatically redact text as you type, you can enable the "Auto Update Mode". This only applies to the text redaction component on the Container Playground. You can do so by adding the `auto=true` query parameter at the end of the browser URL. Here is an example:

```text URL theme={"theme":"poimandres"}
http://localhost:3000/text?auto=true
```
