Moderations
Check whether input text contains violence, hate, self-harm or other content that may violate safety policies.
Endpoint
http
POST https://api.nexusmodels.cn/v1/moderationsHeaders
http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/jsonRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | No | Moderation model; may be omitted when a server default is configured |
input | string or array | Yes | Text content to check |
Single input example
bash
curl -sS -X POST \
'https://api.nexusmodels.cn/v1/moderations' \
-H 'Authorization: Bearer YOUR_NEXUSMODELS_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "YOUR_MODERATION_MODEL",
"input": "Text content that needs a safety check"
}'Batch input example
bash
curl -sS -X POST \
'https://api.nexusmodels.cn/v1/moderations' \
-H 'Authorization: Bearer YOUR_NEXUSMODELS_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "YOUR_MODERATION_MODEL",
"input": [
"The first item to check",
"The second item to check"
]
}'Response example
json
{
"id": "moderation-request-id",
"model": "YOUR_MODERATION_MODEL",
"results": [
{
"flagged": false,
"categories": {
"hate": false,
"harassment": false,
"self-harm": false,
"sexual": false,
"violence": false
},
"category_scores": {
"hate": 0.0001,
"harassment": 0.0002,
"self-harm": 0.0001,
"sexual": 0.0001,
"violence": 0.0003
}
}
]
}Response fields
| Field | Description |
|---|---|
flagged | Whether the input may violate a safety policy |
categories | Whether each safety category was detected |
category_scores | Model score for each safety category |