Skip to content

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/moderations

Headers

http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY
Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
modelstringNoModeration model; may be omitted when a server default is configured
inputstring or arrayYesText 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

FieldDescription
flaggedWhether the input may violate a safety policy
categoriesWhether each safety category was detected
category_scoresModel score for each safety category