Text & embeddings
Moderations
Check text and images for potentially harmful content.
POST
/v1/moderations
Compatible with the OpenAI Moderations API. Classifies input against categories such as harassment, hate, self-harm, sexual content and violence, so you can filter user input or model output.
Authentication
Authorization: Bearer sk-xxxx
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
input |
string | array | Yes | Text, an array of texts, or (for omni-moderation-*) an array of text / image_url parts. |
model |
string | No | omni-moderation-latest (text and images) or text-moderation-latest. If omitted, a default moderation model is used — specify it explicitly for predictable results. |
Request example
cURL
curl https://rutoken.ai/v1/moderations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "omni-moderation-latest",
"input": "I want to hurt someone."
}'
Python
from openai import OpenAI
client = OpenAI(base_url="https://rutoken.ai/v1", api_key="sk-xxxx")
resp = client.moderations.create(
model="omni-moderation-latest",
input="I want to hurt someone.",
)
print(resp.results[0].flagged)
Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://rutoken.ai/v1", apiKey: "sk-xxxx" });
const resp = await client.moderations.create({
model: "omni-moderation-latest",
input: "I want to hurt someone.",
});
console.log(resp.results[0].flagged);
Image and text together:
json
{
"model": "omni-moderation-latest",
"input": [
{"type": "text", "text": "Check this picture"},
{"type": "image_url", "image_url": {"url": "https://example.com/image.png"}}
]
}
Response
json
{
"id": "modr-970d409ef3bef3b70c73d8232df86e7d",
"model": "omni-moderation-latest",
"results": [
{
"flagged": true,
"categories": {
"harassment": false,
"harassment/threatening": false,
"hate": false,
"self-harm": false,
"sexual": false,
"violence": true,
"violence/graphic": false
},
"category_scores": {
"harassment": 0.0412,
"harassment/threatening": 0.0281,
"hate": 0.0007,
"self-harm": 0.0002,
"sexual": 0.0001,
"violence": 0.8977,
"violence/graphic": 0.0012
}
}
]
}
The category list is shortened here.
| Field | Type | Description |
|---|---|---|
results[].flagged |
boolean | true if any category is flagged. |
results[].categories |
object | Per-category boolean verdicts. |
results[].category_scores |
object | Per-category confidence scores, 0–1. |
results[].category_applied_input_types |
object | omni-moderation-* only: which input types (text, image) each category was applied to. |