Prompt Privacy API
Prompt Privacy's API stands out for its exceptional capabilities, enabling users to effectively call their models with ease. It incorporates advanced features such as vector vaults, which enhance the data handling and processing capabilities. Additionally, the API facilitates seamless integration with the Prompt Store, allowing users to trigger a wide array of prompts. This combination of features makes the API not only powerful but also versatile, catering to a broad range of use cases and applications.
Enabling your API Key
On the Developer Options screen, you are provided with the tools to manage the Prompt Privacy API keys associated with your user account.
Visit https://console.promptprivacy.com/dashboard/developer-option
- Toggle the "Developer Options" to "Enable"
- Select the “Create API Key” Button.
- Name the API key and select the “Generate” Button.
- Copy the API Key for use in your application
- API Utilization
How to Call the API
Python
import requests
import json
url = "https://apigateway.promptprivacy.com"
payload = json.dumps({
"tenant_id": "{YOUR_TENANT_ID}",
"model": "chatgpt_3_5",
"prompts": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Write a function to add 5 and 4 in python"
}
]
})
headers = {
'Content-Type': 'application/json',
'api-key': {YOUR_API_KEY}'
}
NodeJS
const url = "https://apigateway.promptprivacy.com";
const payload = {
tenant_id: "{YOUR_TENANT_ID}",
model: "chatgpt_3_5",
prompts: [
{
role: "system",
content: "You are a helpful assistant."
},
{
role: "user",
content: "Write a function to add 5 and 4 in python"
}
]
};
const headers = {
'Content-Type': 'application/json',
'api-key': '{YOUR_API_KEY}'
};
fetch(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Curl
curl --location 'https://apigateway.promptprivacy.com' \
--header 'Content-Type: application/json' \
--header 'api-key: {YOUR_API_KEY}' \
--data '{
"tenant_id": "{YOUR_TENANT_ID}",
"model": "chatgpt_3_5",
"prompts": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Write a function to add 5 and 4 in python"
}
]}'
.NET
using System;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
class Program
{
static async System.Threading.Tasks.Task Main(string[] args)
{
// URL of the API gateway
var url = "https://apigateway.promptprivacy.com";
// Create the payload as an anonymous object
var payload = new
{
tenant_id = "{YOUR_TENANT_ID}",
model = "chatgpt_3_5",
prompts = new[]
{
new { role = "system", content = "You are a helpful assistant." },
new { role = "user", content = "Write a function to add 5 and 4 in python" }
}
};
// Serialize the payload to JSON
var jsonPayload = JsonConvert.SerializeObject(payload);
// Create HttpClient instance
using (var httpClient = new HttpClient())
{
// Set up the request headers
httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
httpClient.DefaultRequestHeaders.Add("api-key", "{YOUR_API_KEY}");
// Create StringContent
var content = new StringContent(jsonPayload, Encoding.UTF8, "application/json");
// Send POST request
var response = await httpClient.PostAsync(url, content);
// Get the response content
var responseString = await response.Content.ReadAsStringAsync();
// Output the response
Console.WriteLine(responseString);
}
}
}
Error Responses
Invalid API Key:
{
"message": "Invalid API Key",
"success": false
}
Invalid Tenant ID:
{
"message": "Invalid Tenant",
"success": false
}