内容审核
curl --request POST \
--url https://openp.ai/v1/moderationsimport 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_bodyOpenAI 兼容
内容审核
POST /v1/moderations —— OpenAI 内容安全分类
POST
/
v1
/
moderations
内容审核
curl --request POST \
--url https://openp.ai/v1/moderationsimport 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."
}'
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | omni-moderation-latest(推荐)或 text-moderation-latest | |
input | string | 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 通常不收取费用(以控制台显示为准)。⌘I