Skip to main content
POST
/
v1
/
moderations
Moderations
curl --request POST \
  --url https://openp.ai/v1/moderations
import requests

url = "https://openp.ai/v1/moderations"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://openp.ai/v1/moderations', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://openp.ai/v1/moderations",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://openp.ai/v1/moderations"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/v1/moderations")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/v1/moderations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
Score text (or images) across several content categories, returning a flag and score for each category.

Request

curl https://openp.ai/v1/moderations \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "omni-moderation-latest",
    "input": "I want to hurt myself."
  }'

Parameters

FieldTypeRequiredDescription
modelstringomni-moderation-latest (recommended) or text-moderation-latest
inputstring | arrayThe text to check, or a multimodal array (the omni model supports images)

Response

{
  "id": "modr-...",
  "model": "omni-moderation-latest",
  "results": [
    {
      "flagged": true,
      "categories": {
        "self-harm": true,
        "self-harm/intent": true,
        "violence": false,
        "sexual": false
      },
      "category_scores": {
        "self-harm": 0.94,
        "self-harm/intent": 0.91,
        "violence": 0.01
      }
    }
  ]
}
flagged: true means any category was triggered.

Multimodal (image) input

{
  "model": "omni-moderation-latest",
  "input": [
    {"type": "text", "text": "Look at this image"},
    {"type": "image_url", "image_url": {"url": "https://..."}}
  ]
}

Categories

CategoryMeaning
sexualSexual content
sexual/minorsInvolving minors
harassmentHarassment
harassment/threateningThreatening harassment
hateHate
hate/threateningThreatening hate
illicitIllicit behavior
illicit/violentViolent illicit
self-harmSelf-harm
self-harm/intentSelf-harm intent
self-harm/instructionsSelf-harm instructions
violenceViolence
violence/graphicGraphic violence

Billing

The OpenAI Moderation endpoint is provided free by OpenAI, and OpenPAI usually doesn’t charge for it (subject to the console display).