Moderations
Detect potentially unsafe content (hate, violence, sexual, self-harm, etc.) so you can filter inputs / outputs before or after calling generation endpoints.
Create a moderation
POST /v1/moderationsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Moderation model, e.g. omni-moderation-latest |
input | string | array | Yes | Text to moderate, or an array of texts |
Request
bash
curl https://ai.youqi.tech/v1/moderations \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "omni-moderation-latest",
"input": "Some text to be moderated."
}'Response
json
{
"id": "modr-abc123",
"model": "omni-moderation-latest",
"results": [
{
"flagged": false,
"categories": {
"hate": false,
"harassment": false,
"self-harm": false,
"sexual": false,
"violence": false
},
"category_scores": {
"hate": 0.00001,
"harassment": 0.00002,
"self-harm": 0.0,
"sexual": 0.00003,
"violence": 0.00001
}
}
]
}Response fields
| Field | Type | Description |
|---|---|---|
results[].flagged | boolean | Whether any category was triggered |
results[].categories | object | Per-category boolean flags |
results[].category_scores | object | Per-category confidence scores (0–1) |