This guide will help you get started in just a few steps. For more information, see:
Before invoking API methods, you first need an API key. Here’s how to get one:
The API key must be passed in every request in one of two ways:
Authorization: Bearer <your-key>
client_id
query parameter (when communicating with the API from a browser)In this guide, we’ll assume you decided to use a bearer header and make requests from a server.
To query the API, you can use any HTTP client, language, or framework.
In this guide, we’ll use Node.js "fetch" to make HTTP requests.
// API URL and your token
const baseUrl = 'https://api.quickai.work';
const apiToken = 'ser_1234567890abcdef';
// Request headers
const headers = {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json' // !important
};
const userInput = req.body.input;
const context = 'Specialist appointment site, new service title';
// Request moderation
const response = await fetch(`${baseUrl}/checkContextInput`, {
method: 'POST',
headers: headers,
body: JSON.stringify({
context: context,
prompt: userInput
})
})
const result = await response.json();
if (result.accepted === false) {
// The input is rejected, you should not proceed
// result.reason contains the detailed reason why the input was rejected
throw new HTTPException(400, result.reason);
}
// The input is accepted, you can proceed
Note: The latest API documentation is available here, with in-depth explanations for each method and parameter. This guide is intended to get you started quickly and assumes you’re familiar with programming, correctly handling errors, adequately securing, etc.