Content moderation
🌐 API endpoint
https://api.exoapi.dev/content-moderation
📃 Description
Automatically detect unwanted content and enforce your moderation rules
️ Request example
// npm install @flower-digital/exoapi-sdk
import { ExoAPI } from "@flower-digital/exoapi-sdk";

const exoapi = new ExoAPI({ apiKey: YOUR_API_KEY });

async function contentModeration() {
  try {
    const res = await exoapi.contentModeration({
      text: "I love this restaurant, the view isn't nice but the food is always great!",
      image:
        "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNkYPhfz0AEYBxVSF+FAP5FDvcfRYWgAAAAAElFTkSuQmCC",
      keywords: {
        negative: ["awful", "terrible"],
        important: "config.keywords",
      },
    });
    console.log(res);
  } catch (err) {
    console.error(err);
  }
}

contentModeration();
️ Request parameters
NameTypeExampleDescription
text
string
I love this restaurant, the view isn't nice but the food is always great!
Text to analyse (500 characters maximum, text exceeding that will be counted as multiple requests)
image
base64
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNkYPhfz0AEYBxVSF+FAP5FDvcfRYWgAAAAAElFTkSuQmCC
Base64-encoded image to analyse (5 MB maximum size, must be of type "png", "jpeg", "webp", "heic", "heif")
keywords
object
{ "negative": [ "awful", "terrible" ], "important": "config.keywords" }
Categories of words to detect in the content. Each category is either an array of words or a datastore key pointing to an array of words (see more in the Datastore documentation)
keywords.category
array string
[ "awful", "terrible" ]
Array of words to detect or datastore key pointing to an array of words (see more in the Datastore documentation)
️ Response example
{
  "safetyScore": 1,
  "reason": "Positive sentiment with a minor complaint about the view.",
  "hateSpeechScore": 0,
  "dangerousContentScore": 0,
  "harassmentScore": 0,
  "sexuallyExplicitScore": 0,
  "spamScore": 0,
  "keywordMatches": {
    "negative": [],
    "important": [
      "food"
    ]
  }
}
️ Response data
NameTypeExampleDescription
safetyScore
number
0.9
Score between 0 and 1 expressing how safe the content is
reason
string
Positive sentiment with a minor complaint about the view.
Short explanation of the text moderation analysis
hateSpeechScore
number
0.08
Probability between 0 and 1 of the text containing hate speech
dangerousContentScore
number
0.16
Probability between 0 and 1 of the text containing dangerous elements
harassmentScore
number
0.14
Probability between 0 and 1 of the text containing harassment
sexuallyExplicitScore
number
0.11
Probability between 0 and 1 of the text containing sexually explicit language
spamScore
number
0.07
Probability between 0 and 1 of the text containing spam or clikbait content
keywordMatches
object
{ "negative": [], "important": [ "food" ] }
Indicates the detected keywords for each category, if any
keywordMatches.category
array
[ "food" ]
Indicates the detected keywords for the given category, if any