Moderations

Learn how to use the moderations endpoint of OpenAI to tag speech with various flags like hate speech, violence, self-harm etc.

The moderations endpoint

Moderations is an endpoint that OpenAI provides to flag text. This API endpoint analyzes the text provided and evaluates whether the content complies with Open AI's usage policies. After the API analyzes the text, it tells the user which flags fit the text and the confidence that the API has for each flag.

Press + to interact
Moderations
Moderations

Moderations API call

To analyze a chunk of text, we can call the following function:

response = client.moderations.create(input="Text to analyze.")

Understanding the moderations endpoint

Let’s look at the moderation endpoint in more detail, reviewing the various models, the request parameters, and the response parameters.

Moderation models

Moderation contains two models that achieve the same result. However, they differ in their approach to updates. Let's examine ...