API Reference
- Introduction
- Authentication
- Headers
- Errors
- Supported Providers
- SDKs
- API Details
Chat Completions
Portkey Endpoints
Embeddings
Other APIs
Completions
Moderations
Fine-tuning
Assistants
- Assistants
- Threads
- Messages
- Runs
- Run Steps
Moderations
curl https://api.portkey.ai/v1/moderations \
-H "Content-Type: application/json" \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \
-d '{
"input": "I want to kill them."
}'
{
"id": "<string>",
"model": "<string>",
"results": [
{
"flagged": true,
"categories": {
"hate": true,
"hate/threatening": true,
"harassment": true,
"harassment/threatening": true,
"self-harm": true,
"self-harm/intent": true,
"self-harm/instructions": true,
"sexual": true,
"sexual/minors": true,
"violence": true,
"violence/graphic": true
},
"category_scores": {
"hate": 123,
"hate/threatening": 123,
"harassment": 123,
"harassment/threatening": 123,
"self-harm": 123,
"self-harm/intent": 123,
"self-harm/instructions": 123,
"sexual": 123,
"sexual/minors": 123,
"violence": 123,
"violence/graphic": 123
}
}
]
}
Body
The input text to classify
"I want to kill them."
Two content moderations models are available: text-moderation-stable
and text-moderation-latest
.
The default is text-moderation-latest
which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use text-moderation-stable
, we will provide advanced notice before updating the model. Accuracy of text-moderation-stable
may be slightly lower than for text-moderation-latest
.
"text-moderation-stable"
Response
Represents if a given text input is potentially harmful.
The unique identifier for the moderation request.
The model used to generate the moderation results.
A list of moderation objects.
Whether any of the below categories are flagged.
A list of the categories, and whether they are flagged or not.
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.
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.
Content that expresses, incites, or promotes harassing language towards any target.
Harassment content that also includes violence or serious harm towards any target.
Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.
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.
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.
Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).
Sexual content that includes an individual who is under 18 years old.
Content that depicts death, violence, or physical injury.
Content that depicts death, violence, or physical injury in graphic detail.
A list of the categories along with their scores as predicted by model.
The score for the category 'hate'.
The score for the category 'hate/threatening'.
The score for the category 'harassment'.
The score for the category 'harassment/threatening'.
The score for the category 'self-harm'.
The score for the category 'self-harm/intent'.
The score for the category 'self-harm/instructions'.
The score for the category 'sexual'.
The score for the category 'sexual/minors'.
The score for the category 'violence'.
The score for the category 'violence/graphic'.
Was this page helpful?
curl https://api.portkey.ai/v1/moderations \
-H "Content-Type: application/json" \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \
-d '{
"input": "I want to kill them."
}'
{
"id": "<string>",
"model": "<string>",
"results": [
{
"flagged": true,
"categories": {
"hate": true,
"hate/threatening": true,
"harassment": true,
"harassment/threatening": true,
"self-harm": true,
"self-harm/intent": true,
"self-harm/instructions": true,
"sexual": true,
"sexual/minors": true,
"violence": true,
"violence/graphic": true
},
"category_scores": {
"hate": 123,
"hate/threatening": 123,
"harassment": 123,
"harassment/threatening": 123,
"self-harm": 123,
"self-harm/intent": 123,
"self-harm/instructions": 123,
"sexual": 123,
"sexual/minors": 123,
"violence": 123,
"violence/graphic": 123
}
}
]
}