Quickstart Guide

This quickstart guide covers how to set up and run the Private AI container.

info

If you'd like to use the Private AI-hosted API, which includes the free demo, please create a portal account and use the code examples provided in the portal.

Setting up the Container

The Private AI container can be deployed anywhere, but mostly commonly we see customer deployments on AWS and Azure. In all production deployments we recommend a Kubernetes deployment. For detailed installation instructions please see our installation guides.

Logging into the Customer Portal

When you are onboarded, a customer portal account will be created for you. In the portal you can find helpful links, download your license file and instructions on how to login to our container registry and pull the latest container image.

If you haven't received this information yet during your onboarding, please contact our customer support team via your dedicated Slack channel, or at support@private-ai.com

Getting the Container

Once you've logged into the customer portal, you will find some commands to get the latest container. The container is distributed via a container registry on Azure, which you can login to with the command found in the portal that looks like this:

Copy
Copied
docker login -u INSERT_UNIQUE_CLIENT_ID -p INSERT_UNIQUE_CLIENT_PW crprivateaiprod.azurecr.io

Please reach out to our customer support if you are experiencing issues.

Getting a License

When you are logged into the customer portal, you should find the license file (or files) assigned to your account in the top right of the main page. There will be a download link beside the file along with information about the license tier and expiry date.

Starting up the Container

Starting with 3.0, license files are used for authentication. To start the container, please mount the license file as follows:

Copy
Copied
docker run --rm -v "full path to your license.json file":/app/license/license.json \
-p 8080:8080 -it crprivateaiprod.azurecr.io/deid:<tag>

For example:

Copy
Copied
docker run --rm -v "/home/johnsmith/paisandbox/my-license-file.json":/app/license/license.json \
-p 8080:8080 -it crprivateaiprod.azurecr.io/deid:3.0.0-cpu

Sending Requests

You can then make a request to the container like this:

cURLPythonPython Client
Copy
Copied
curl --request POST --url http://localhost:8080/v3/process/text --header 'Content-Type: application/json' --data '{"text": ["Hello John"]}'
Copy
Copied
import requests

r = requests.post(url="http://localhost:8080/v3/process/text",                  
                  json={"text": ["Hello John"]})

results = r.json()

print(results)
Copy
Copied
from privateai_client import PAIClient
from privateai_client import request_objects

client = PAIClient(url="http://localhost:8080")

text_request = request_objects.process_text_obj(text=["Hello John"])
response = client.process_text(text_request)

print(response.processed_text)

Processing Files

Processing files can be done by sending base64-encoded files to the /v3/process/files/base64 route:

PythonPython Client
Copy
Copied
import base64
import requests

# Specify the input and output file paths
filename_in = "<input filename>"
filename_out = "<output filename>"

# Read the file and do base64 encoding
with open(filename_in, "rb") as f:
    b64_file_content = base64.b64encode(f.read())
    b64_file_content = b64_file_content.decode("utf-8")

# Make the request and load the results as JSON
r = requests.post(url="http://localhost:8080/v3/process/files/base64", 
                  json={"file": {"data": b64_file_content, "content_type": "image/jpg"}})
results = r.json()

# Decode and write the file to disk
with open(filename_out, "wb") as f:
    f.write(base64.b64decode(results["processed_file"]))
Copy
Copied
from privateai_client import PAIClient
from privateai_client.objects import request_objects
import base64

# Specify the input and output file paths
filename_in = "sample.pdf"
filename_out = "sample.redacted.pdf"

file_type= "application/pdf"
client = PAIClient(url="http://localhost:8080")

# Read from file
with open(filename_in, "rb") as b64_file:
    file_data = base64.b64encode(b64_file.read())
    file_data = file_data.decode("ascii")

# Make the request
file_obj = request_objects.file_obj(data=file_data, content_type=file_type)
request_obj = request_objects.file_base64_obj(file=file_obj)
resp = client.process_files_base64(request_object=request_obj)

# Write to file
with open(filename_out, 'wb') as redacted_file:
    processed_file = resp.processed_file.encode("ascii")
    processed_file = base64.b64decode(processed_file, validate=True)
    redacted_file.write(processed_file)

It is also possible to send URIs instead to the /v3/process/files/uri route, avoiding the overhead of base64 encoding and avoiding sending any sensitive information in the request. Please see Running the Container for details.

© Copyright 2024 Private AI.