Skip to main content
POST
/
paas
/
v4
/
moderations
内容安全
curl --request POST \
  --url https://open.bigmodel.cn/api/paas/v4/moderations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "moderation",
  "input": "审核内容安全样例字符串。"
}
'
import requests

url = "https://open.bigmodel.cn/api/paas/v4/moderations"

payload = {
"model": "moderation",
"input": "审核内容安全样例字符串。"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: 'moderation', input: '审核内容安全样例字符串。'})
};

fetch('https://open.bigmodel.cn/api/paas/v4/moderations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
HttpResponse<String> response = Unirest.post("https://open.bigmodel.cn/api/paas/v4/moderations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"moderation\",\n \"input\": \"审核内容安全样例字符串。\"\n}")
.asString();
package main

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

func main() {

url := "https://open.bigmodel.cn/api/paas/v4/moderations"

payload := strings.NewReader("{\n \"model\": \"moderation\",\n \"input\": \"审核内容安全样例字符串。\"\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

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

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

fmt.Println(string(body))

}
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://open.bigmodel.cn/api/paas/v4/moderations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'moderation',
'input' => '审核内容安全样例字符串。'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

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

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
  "id": "<string>",
  "created": 123,
  "request_id": "<string>",
  "result_list": [
    {
      "content_type": "<string>",
      "risk_level": "<string>",
      "risk_type": [
        "<string>"
      ]
    }
  ],
  "usage": {
    "moderation_text": {
      "call_count": 123
    }
  }
}
{
"error": {
"code": "<string>",
"message": "<string>"
}
}

Authorizations

Authorization
string
header
required

标准的 HTTP Bearer 认证方式,在 API Keys 页面获取密钥。

Body

application/json
model
enum<string>
default:moderation
required

安全模型

Available options:
moderation
input
required

需要审核的内容 纯文本字符串(最大输入长度:2000 字符) 多媒体对象(type+url) 图片:图片小于 10M,最低分辨率 20* 20,不超过 6000 * 6000 视频:推荐视频时长 30 秒 音频:推荐音频时长 60

Example:

"审核内容安全样例字符串。"

Response

业务处理成功

id
string

任务 ID

created
integer

请求创建时间,是以秒为单位的 Unix 时间戳

request_id
string

请求标识符

result_list
object[]
usage
object