Content moderation with AI: Quick-start Guide

The QuickAI API allows you to integrate advanced AI moderation and analysis capabilities into your application quickly and easily.

This guide will help you get started in just a few steps. For more information, see:

Before You Begin

Before invoking API methods, you first need an API key. Here’s how to get one:

  1. Sign In using GitHub or Google with a single click.
  2. After logging in, navigate to the dashboard and obtain your personal API key.
  3. Keep your API key secure — this token is used to authenticate your requests.

Authentication

The API key must be passed in every request in one of two ways:

  • In the HTTP header: Authorization: Bearer <your-key>
  • As the 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.

Querying the API

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.