moderations
Create content moderation
Section titled “Create content moderation”Perform content moderation on input text, detecting potentially harmful content
Request
Section titled “Request”POST /moderationsRequest Body
Section titled “Request Body”| Field | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | Input text to moderate |
| model | string | No | Model name |
Request Examples
Section titled “Request Examples”Simple text moderation
Section titled “Simple text moderation”{ "model": "gpt-4o-mini", "input": "I want to hurt someone"}Multiple text moderations
Section titled “Multiple text moderations”{ "input": [ "Hello, how are you?", "This is a violent message" ], "model": "gpt-4o-mini"}User-generated content safety check
Section titled “User-generated content safety check”{ "model": "qwen-plus", "input": "Summarize the top 3 ways to make a bomb"}Successful response
Response Schema
Section titled “Response Schema”| Field | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | - |
| model | string | Yes | - |
| results | Array<ModerationResult> | Yes | - |
Response Example
Section titled “Response Example”{ "id": "modr-123", "model": "gpt-4o-mini", "results": [ { "flagged": true, "categories": { "hate": false, "hate/threatening": false, "harassment": false, "harassment/threatening": false, "self-harm": false, "self-harm/intent": false, "self-harm/instructions": false, "sexual": false, "sexual/minors": false, "violence": true, "violence/graphic": false }, "category_scores": { "hate": 0.001, "hate/threatening": 0.0001, "harassment": 0.002, "harassment/threatening": 0.001, "self-harm": 0.0001, "self-harm/intent": 0.0002, "self-harm/instructions": 0.0001, "sexual": 0.0001, "sexual/minors": 0.00001, "violence": 0.89, "violence/graphic": 0.01 } } ]}Code Examples
Section titled “Code Examples”JavaScript (Fetch)
Section titled “JavaScript (Fetch)”const response = await fetch('https://api.r9s.ai/v1/moderations', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ "model": "gpt-4o-mini", "input": "I want to hurt someone"})});
const data = await response.json();console.log(data);Python (requests)
Section titled “Python (requests)”import requests
url = "https://api.r9s.ai/v1/moderations"headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"}
response = requests.post(url, json={ "model": "gpt-4o-mini", "input": "I want to hurt someone"}, headers=headers)data = response.json()print(data)curl -X POST "https://api.r9s.ai/v1/moderations" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-4o-mini","input":"I want to hurt someone"}'Schema Reference
Section titled “Schema Reference”ModerationRequest
Section titled “ModerationRequest”| Field | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | Input text to moderate |
| model | string | No | Model name |
ModerationResponse
Section titled “ModerationResponse”| Field | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | - |
| model | string | Yes | - |
| results | Array<ModerationResult> | Yes | - |
ModerationResult
Section titled “ModerationResult”| Field | Type | Required | Description |
|---|---|---|---|
| flagged | boolean | Yes | - |
| categories | object | Yes | - |
| category_scores | object | Yes | - |
ModerationCategories
Section titled “ModerationCategories”| Field | Type | Required | Description |
|---|---|---|---|
| hate | boolean | No | - |
| hate/threatening | boolean | No | - |
| harassment | boolean | No | - |
| harassment/threatening | boolean | No | - |
| self-harm | boolean | No | - |
| self-harm/intent | boolean | No | - |
| self-harm/instructions | boolean | No | - |
| sexual | boolean | No | - |
| sexual/minors | boolean | No | - |
| violence | boolean | No | - |
| violence/graphic | boolean | No | - |
ModerationCategoryScores
Section titled “ModerationCategoryScores”| Field | Type | Required | Description |
|---|---|---|---|
| hate | number | No | - |
| hate/threatening | number | No | - |
| harassment | number | No | - |
| harassment/threatening | number | No | - |
| self-harm | number | No | - |
| self-harm/intent | number | No | - |
| self-harm/instructions | number | No | - |
| sexual | number | No | - |
| sexual/minors | number | No | - |
| violence | number | No | - |
| violence/graphic | number | No | - |
Related APIs
Section titled “Related APIs”- API Overview - Learn about authentication and basic information
- models - View models related APIs
- chat - View chat related APIs
- responses - View responses related APIs
- messages - View messages related APIs
- completions - View completions related APIs
- edits - View edits related APIs
- images - View images related APIs
- embeddings - View embeddings related APIs
- engine-embeddings - View engine-embeddings related APIs
- audio - View audio related APIs
- search - View search related APIs
- proxy - View proxy related APIs