跳转到主要内容
POST
/
v1
/
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
对文本(或图片)按多个内容类别打分,返回每个类别的命中标志与得分。

请求

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."
  }'

参数

字段类型必填说明
modelstringomni-moderation-latest(推荐)或 text-moderation-latest
inputstring | array待检查的文本或多模态数组(omni 模型支持图片)

响应

{
  "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 表示触发任意类别。

多模态(图片)输入

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

类别

类别含义
sexual色情内容
sexual/minors涉及未成年人
harassment骚扰
harassment/threatening威胁性骚扰
hate仇恨
hate/threatening威胁性仇恨
illicit非法行为
illicit/violent暴力非法
self-harm自我伤害
self-harm/intent自伤意图
self-harm/instructions自伤指导
violence暴力
violence/graphic血腥暴力

计费

OpenAI Moderation 接口由官方 免费 提供,OpenPAI 通常不收取费用(以控制台显示为准)。