Moderation API
The moderation endpoint allows you to analyze text and optionally images for potentially harmful content using AI moderation models through a single, unified API. This endpoint supports checking content against various categories such as sexual content, hate speech, harassment, self-harm, and violence.
Endpoint
POST https://api.llm.vin/v1/moderations
Request Format
{
"model": "moderation-1",
"input": "Text to analyze for moderation",
"input_images": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."]
}
Required Parameters
Parameter | Type | Description |
---|---|---|
input |
string or array of strings | The text content to analyze for moderation. Can be a single string or an array of strings for batch processing. |
Optional Parameters
Parameter | Type | Default | Description |
---|---|---|---|
model |
string | Default moderation model | ID of the model to use for moderation. If not specified, the default moderation model is used. See Available Models below. |
input_images |
array of strings | [] | An array of base64-encoded image data URLs to analyze alongside text. Only supported by models with image input capability. |
Response Format
{
"id": "modr-1716151540",
"model": "moderation-1",
"results": [
{
"flagged": true,
"categories": {
"sexual": false,
"hate": true,
"harassment": false,
"self-harm": false,
"sexual/minors": false,
"hate/threatening": false,
"violence/graphic": false,
"self-harm/intent": false,
"self-harm/instructions": false,
"harassment/threatening": false,
"violence": false
},
"category_scores": {
"sexual": 0.1,
"hate": 0.9,
"harassment": 0.2,
"self-harm": 0.05,
"sexual/minors": 0.01,
"hate/threatening": 0.3,
"violence/graphic": 0.1,
"self-harm/intent": 0.02,
"self-harm/instructions": 0.01,
"harassment/threatening": 0.15,
"violence": 0.2
}
}
]
}
The response contains:
id
: A unique identifier for the moderation request.model
: The ID of the model used for moderation.results
: An array of moderation results, one for each input (text or text+image pair), containing:flagged
: Boolean indicating if the content violates any moderation category.categories
: Object with boolean values indicating whether each category was violated.category_scores
: Object with confidence scores (0 to 1) for each category.
Available Models
The available moderation models depend on the configuration and are listed via the /v1/models
endpoint. Only models with the moderation
capability set to true
can be used. Use the /v1/models
endpoint to discover available models and their capabilities.
Model ID | Description |
---|---|
moderation-1 |
Model designed for content moderation with text and/or image analysis capabilities |
Example Requests
Basic Text Moderation
curl "https://api.llm.vin/v1/moderations" \
-H "Content-Type: application/json" \
-d '{
"input": "This content contains hateful language."
}'
Batch Text Moderation
curl "https://api.llm.vin/v1/moderations" \
-H "Content-Type: application/json" \
-d '{
"input": ["Text one", "Text two with inappropriate content"],
"model": "moderation-1"
}'
Text and Image Moderation
curl "https://api.llm.vin/v1/moderations" \
-H "Content-Type: application/json" \
-d '{
"model": "moderation-1",
"input": "Text to moderate",
"input_images": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ..."]
}'
Error Handling
The API returns standard HTTP status codes to indicate success or failure:
Status Code | Description |
---|---|
200 | Success |
400 | Bad request (missing or invalid parameters, unsupported capability) |
401 | Unauthorized (invalid or missing API key) |
403 | Forbidden (insufficient permissions for model) |
404 | Not found (invalid model) |
429 | Too many requests (rate limit exceeded) |
500 | Server error |
Error responses include a JSON object with details:
{
"error": {
"message": "Model 'gpt-4.1' does not support moderation",
"type": "invalid_request_error",
"code": "unsupported_capability"
}
}
Notes
- The default moderation model is used if no
model
parameter is specified, provided one is configured and available. - Image moderation is only supported by models with the
image_input
capability set totrue
. - The moderation categories and their scores are determined by the underlying model and may vary based on the platform and model configuration.
- Ensure that
input_images
contains valid base64-encoded image data URLs when used.