# 内容审核

### 创建内容审核

```
POST https://api.openai.com/v1/moderations
```

判断文本是否违反OpenAI的内容政策

#### 请求体

* input 字符串或数组 必填项 需要分类的输入文本
* model 字符串 可选的 默认为text-moderation-latest 有两个内容审核模型可用：text-moderation-stable和text-moderation-latest。默认设置为text-moderation-latest，这将随着时间的推移自动升级。这确保您始终使用我们最准确的模型。如果您使用text-moderation-stable，我们将提前通知您更新模型。text-moderation-stable的准确性可能略低于text-moderation-latest。

#### 请求示例

{% tabs %}
{% tab title="curl" %}
{% code lineNumbers="true" %}

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

```

{% endcode %}
{% endtab %}

{% tab title="python" %}
{% code lineNumbers="true" %}

```python
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Moderation.create(
  input="I want to kill them.",
)

```

{% endcode %}
{% endtab %}

{% tab title="node.js" %}
{% code lineNumbers="true" %}

```javascript
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createModeration({
  input: "I want to kill them.",
});

```

{% endcode %}
{% endtab %}
{% endtabs %}

{% code title="请求参数" lineNumbers="true" %}

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

```

{% endcode %}

{% code title="返回结果" lineNumbers="true" %}

```json
{
  "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
    }
  ]
}

```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.luojixiangliang.com/reference/openai-api-can-kao-wen-dang/nei-rong-shen-he.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
