Classify content for policy violations
POST
/v1/moderationsPOST
/v1/moderationsYour instance endpoint, shown on the instance page in the dashboard. Each instance has its own host; there is no shared API host.
Request Body
| Property | Type | Required | Description |
|---|---|---|---|
input | string | No | |
inputs | object[] | No | |
model | string | No | |
metadata | object | No |
Responses
200 Moderation results
| Property | Type | Description |
|---|---|---|
id | string | |
model | string | |
results | object[] |
default An unexpected error response.
| Property | Type | Description |
|---|---|---|
code | integer | |
message | string | |
details | object[] |
Request
curl -X POST "http://localhost:8089/v1/moderations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"string","inputs":[{"type":"string","text":"string","imageUrl":{"url":"string"}}],"model":"string"}'const response = await fetch("http://localhost:8089/v1/moderations", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
"input": "string",
"inputs": [
{
"type": "string",
"text": "string",
"imageUrl": {
"url": "string"
}
}
],
"model": "string"
}),
});
const data = await response.json();import requests
response = requests.post(
"http://localhost:8089/v1/moderations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"input": "string",
"inputs": [
{
"type": "string",
"text": "string",
"imageUrl": {
"url": "string"
}
}
],
"model": "string"
},
)
data = response.json()Response
{
"id": "string",
"model": "string",
"results": [
{
"flagged": true,
"categories": {
"hate": true,
"hateThreatening": true,
"harassment": true,
"harassmentThreatening": true,
"illicit": true,
"illicitViolent": true,
"selfHarm": true,
"selfHarmIntent": true,
"selfHarmInstructions": true,
"sexual": true,
"sexualMinors": true,
"violence": true,
"violenceGraphic": true
},
"categoryScores": {
"hate": 0,
"hateThreatening": 0,
"harassment": 0,
"harassmentThreatening": 0,
"illicit": 0,
"illicitViolent": 0,
"selfHarm": 0,
"selfHarmIntent": 0,
"selfHarmInstructions": 0,
"sexual": 0,
"sexualMinors": 0,
"violence": 0,
"violenceGraphic": 0
},
"categoryAppliedInputTypes": {
"hate": [],
"hateThreatening": [],
"harassment": [],
"harassmentThreatening": [],
"illicit": [],
"illicitViolent": [],
"selfHarm": [],
"selfHarmIntent": [],
"selfHarmInstructions": [],
"sexual": [],
"sexualMinors": [],
"violence": [],
"violenceGraphic": []
}
}
]
}{
"code": 0,
"message": "string",
"details": [
{
"@type": "string"
}
]
}
