Getting Started
Obtaining an API key
Every request to PurAI is authenticated with an API key. To create one:
-
Create a PurAI account and open your account dashboard
-
Navigate to the API Keys section
-
Select Create key
-
Your key is displayed once. Store it securely, and never share it or commit it to source control.
Making your first request
You interact with PurAI through standard HTTP POST requests — from cURL, fetch(), or any HTTP client — which makes it easy to use from any platform or language.
A simple demonstration using the chat/completions endpoint is below:
PurAI.js (NodeJS)
const PurAI = require('PurAI.js');
const { OpenAIChatCompletionsMessageRole, OpenAIChatCompletionsModel } = require('PurAI.js/src/types');
const PurAI = new PurAI('YOUR API KEY');
let response = await PurAI.openAI.chat.completions({
messages: [
{
role: OpenAIChatCompletionsMessageRole.User,
content: 'Hello, PurAI!'
}
],
model: OpenAIChatCompletionsModel['GPT-3.5 Turbo'] // ANY DESIRED MODEL
});
console.log(response);Returns:
{
"id": "chatcmpl-7aW8BDCAXErPoazm2dSI1EKEUzKBQ",
"object": "chat.completion",
"created": 1688937675,
"model": "gpt-3.5-turbo-0613",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 9,
"total_tokens": 22
}
}How PurAI is structured
PurAI is simple: you send a POST request to a URL that combines your desired company (openai, for example) and product (chat/completions, for example), and receive the model’s output in response.
The full list of URLs, along with their descriptions, is documented in the following sections.