API文档(api-reference)
调整(Moderations)

内容审核 Moderations

给定输入文本,输出模型是否将其分类为违反OpenAI内容政策。

相关指南:内容审核

内容审核创建Create moderation

post https://api.openai.com/v1/moderations (opens in a new tab)

分类文本是否违反OpenAI的内容政策

请求正文

input 字符串或数组类型,必填项。需要分类的输入文本。

model 字符串类型,可选。默认是 text-moderation-latest。有两个内容审核模型可用:text-moderation-stabletext-moderation-latest

默认值为 text-moderation-latest,它会自动升级。这确保您始终使用我们最准确的模型。如果使用 text-moderation-stable,我们将在更新模型之前提供提前通知。text-moderation-stable 的准确度可能略低于 text-moderation-latest

请求示例(Python方式)

curl https://api.openai.com/v1/moderations 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer $OPENAI_API_KEY" 
  -d '{
    "input": "I want to kill them."
  }'

请求参数(Parameters)

{
 "input": "I want to kill them."
}

响应体 (Response)

{
 "id": "modr-5MWoLO",
 "model": "text-moderation-001",
 "results": [
    {
 "categories": {
 "hate": false,
 "hate/threatening": true,
 "self-harm": false,
 "sexual": false,
 "sexual/minors": false,
 "violence": true,
 "violence/graphic": false
      },
 "category_scores": {
 "hate": 0.22714105248451233,
 "hate/threatening": 0.4132447838783264,
 "self-harm": 0.005232391878962517,
 "sexual": 0.01407341007143259,
 "sexual/minors": 0.0038522258400917053,
 "violence": 0.9223177433013916,
 "violence/graphic": 0.036865197122097015
      },
 "flagged": true
    }
  ]
}