POST
/
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
      }
    }
  ]
}

Authorizations

x-portkey-api-key
string
header
required
x-portkey-virtual-key
string
header
required

Body

application/json
input
default:
required

The input text to classify

Example:

"I want to kill them."

model
default:text-moderation-latest

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.

Example:

"text-moderation-stable"

Response

200 - application/json
OK

Represents if a given text input is potentially harmful.

id
string
required

The unique identifier for the moderation request.

model
string
required

The model used to generate the moderation results.

results
object[]
required

A list of moderation objects.