Skip to content
Primary navigation

Moderations

Given text and/or image inputs, classifies if those inputs are potentially harmful.

resource openai_moderation

required Expand Collapse
input: String

Input (or inputs) to classify. Can be a single string, an array of strings, or an array of multi-modal input objects similar to other models.

optional Expand Collapse
model?: String

The content moderation model you would like to use. Learn more in the moderation guide, and learn about available models here.

computed Expand Collapse
id: String

The unique identifier for the moderation request.

results: List[Attributes]

A list of moderation objects.

categories: Attributes

A list of the categories, and whether they are flagged or not.

harassment: Bool

Content that expresses, incites, or promotes harassing language towards any target.

harassment_threatening: Bool

Harassment content that also includes violence or serious harm towards any target.

hate: Bool

Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.

hate_threatening: Bool

Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.

illicit: Bool

Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, “how to shoplift” would fit this category.

illicit_violent: Bool

Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon.

self_harm: Bool

Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.

self_harm_instructions: Bool

Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.

self_harm_intent: Bool

Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.

sexual: Bool

Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).

sexual_minors: Bool

Sexual content that includes an individual who is under 18 years old.

violence: Bool

Content that depicts death, violence, or physical injury.

violence_graphic: Bool

Content that depicts death, violence, or physical injury in graphic detail.

category_applied_input_types: Attributes

A list of the categories along with the input type(s) that the score applies to.

harassment: List[String]

The applied input type(s) for the category ‘harassment’.

harassment_threatening: List[String]

The applied input type(s) for the category ‘harassment/threatening’.

hate: List[String]

The applied input type(s) for the category ‘hate’.

hate_threatening: List[String]

The applied input type(s) for the category ‘hate/threatening’.

illicit: List[String]

The applied input type(s) for the category ‘illicit’.

illicit_violent: List[String]

The applied input type(s) for the category ‘illicit/violent’.

self_harm: List[String]

The applied input type(s) for the category ‘self-harm’.

self_harm_instructions: List[String]

The applied input type(s) for the category ‘self-harm/instructions’.

self_harm_intent: List[String]

The applied input type(s) for the category ‘self-harm/intent’.

sexual: List[String]

The applied input type(s) for the category ‘sexual’.

sexual_minors: List[String]

The applied input type(s) for the category ‘sexual/minors’.

violence: List[String]

The applied input type(s) for the category ‘violence’.

violence_graphic: List[String]

The applied input type(s) for the category ‘violence/graphic’.

category_scores: Attributes

A list of the categories along with their scores as predicted by model.

harassment: Float64

The score for the category ‘harassment’.

harassment_threatening: Float64

The score for the category ‘harassment/threatening’.

hate: Float64

The score for the category ‘hate’.

hate_threatening: Float64

The score for the category ‘hate/threatening’.

illicit: Float64

The score for the category ‘illicit’.

illicit_violent: Float64

The score for the category ‘illicit/violent’.

self_harm: Float64

The score for the category ‘self-harm’.

self_harm_instructions: Float64

The score for the category ‘self-harm/instructions’.

self_harm_intent: Float64

The score for the category ‘self-harm/intent’.

sexual: Float64

The score for the category ‘sexual’.

sexual_minors: Float64

The score for the category ‘sexual/minors’.

violence: Float64

The score for the category ‘violence’.

violence_graphic: Float64

The score for the category ‘violence/graphic’.

flagged: Bool

Whether any of the below categories are flagged.

openai_moderation

resource "openai_moderation" "example_moderation" {
  input = "I want to kill them."
  model = "string"
}