API Reference
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 multiple filetypes, with the content type being set by the user. A future release will add automatic content type detection.
POST
/
v3
/
process
/
files
/
base64
Process Files Base64
curl --request POST \
--url https://api.private-ai.com/deid/v3/process/files/base64 \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"file": {
"data": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...",
"content_type": "application/pdf or image/jpeg"
},
"entity_detection": {
"accuracy": "high",
"return_entity": true
},
"pdf_options": {
"density": 150
},
"audio_options": {
"bleep_start_padding": 0,
"bleep_end_padding": 0
}
}
'import requests
url = "https://api.private-ai.com/deid/v3/process/files/base64"
payload = {
"file": {
"data": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...",
"content_type": "application/pdf or image/jpeg"
},
"entity_detection": {
"accuracy": "high",
"return_entity": True
},
"pdf_options": { "density": 150 },
"audio_options": {
"bleep_start_padding": 0,
"bleep_end_padding": 0
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file: {
data: 'JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...',
content_type: 'application/pdf or image/jpeg'
},
entity_detection: {accuracy: 'high', return_entity: true},
pdf_options: {density: 150},
audio_options: {bleep_start_padding: 0, bleep_end_padding: 0}
})
};
fetch('https://api.private-ai.com/deid/v3/process/files/base64', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.private-ai.com/deid/v3/process/files/base64",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file' => [
'data' => 'JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...',
'content_type' => 'application/pdf or image/jpeg'
],
'entity_detection' => [
'accuracy' => 'high',
'return_entity' => true
],
'pdf_options' => [
'density' => 150
],
'audio_options' => [
'bleep_start_padding' => 0,
'bleep_end_padding' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.private-ai.com/deid/v3/process/files/base64"
payload := strings.NewReader("{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.private-ai.com/deid/v3/process/files/base64")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.private-ai.com/deid/v3/process/files/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"processed_file": "<string>",
"processed_text": "<string>",
"entities": [
{
"processed_text": "<string>",
"text": "<string>",
"location": {
"stt_idx": 123,
"end_idx": 123,
"stt_idx_processed": 123,
"end_idx_processed": 123
},
"best_label": "<string>",
"labels": {}
}
],
"entities_present": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Response
Successful Response
⌘I
Process Files Base64
curl --request POST \
--url https://api.private-ai.com/deid/v3/process/files/base64 \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"file": {
"data": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...",
"content_type": "application/pdf or image/jpeg"
},
"entity_detection": {
"accuracy": "high",
"return_entity": true
},
"pdf_options": {
"density": 150
},
"audio_options": {
"bleep_start_padding": 0,
"bleep_end_padding": 0
}
}
'import requests
url = "https://api.private-ai.com/deid/v3/process/files/base64"
payload = {
"file": {
"data": "JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...",
"content_type": "application/pdf or image/jpeg"
},
"entity_detection": {
"accuracy": "high",
"return_entity": True
},
"pdf_options": { "density": 150 },
"audio_options": {
"bleep_start_padding": 0,
"bleep_end_padding": 0
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
file: {
data: 'JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...',
content_type: 'application/pdf or image/jpeg'
},
entity_detection: {accuracy: 'high', return_entity: true},
pdf_options: {density: 150},
audio_options: {bleep_start_padding: 0, bleep_end_padding: 0}
})
};
fetch('https://api.private-ai.com/deid/v3/process/files/base64', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.private-ai.com/deid/v3/process/files/base64",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'file' => [
'data' => 'JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...',
'content_type' => 'application/pdf or image/jpeg'
],
'entity_detection' => [
'accuracy' => 'high',
'return_entity' => true
],
'pdf_options' => [
'density' => 150
],
'audio_options' => [
'bleep_start_padding' => 0,
'bleep_end_padding' => 0
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.private-ai.com/deid/v3/process/files/base64"
payload := strings.NewReader("{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.private-ai.com/deid/v3/process/files/base64")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.private-ai.com/deid/v3/process/files/base64")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"file\": {\n \"data\": \"JVBERi0xLjQKJdPr6eEKMSAwIG9iago8PC9UaXRsZSAoc2FtcGxlKQovUHJvZHVj...\",\n \"content_type\": \"application/pdf or image/jpeg\"\n },\n \"entity_detection\": {\n \"accuracy\": \"high\",\n \"return_entity\": true\n },\n \"pdf_options\": {\n \"density\": 150\n },\n \"audio_options\": {\n \"bleep_start_padding\": 0,\n \"bleep_end_padding\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"processed_file": "<string>",
"processed_text": "<string>",
"entities": [
{
"processed_text": "<string>",
"text": "<string>",
"location": {
"stt_idx": 123,
"end_idx": 123,
"stt_idx_processed": 123,
"end_idx_processed": 123
},
"best_label": "<string>",
"labels": {}
}
],
"entities_present": true
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}