Moderation Endpoints
moderation.check checks texts and images for harmful content, such as
threats, hate or sexual content, before you publish them. It is part of
All tools.
A start needs the scope and enough credits, and the tool must be available in
/v1/health. Free credits also follow the
free limits. Accepted starts return
202 Accepted; poll their status. The answer is JSON in the operation result.
This endpoint is preview. Preview means the contract may still evolve before stable release.
Shared Access
- Access: Paid plans that include this family, or free credits (guest trial or verified account) within the free limits.
- Operation family: Moderation
- Scope:
api:llm:write, the same scope as the AI model tools - Idempotency:
Idempotency-Keyheader required
POST/v1/moderation/check
Checks one text or a list of texts, and up to four images. Each text and each image gets its own verdict: flagged or not, and for each category whether it was flagged, a score from 0 to 1 and the input types the score applies to.
Required Access
- Credits: 1 per check, for all its texts and images. See moderation pricing.
- Scope:
api:llm:write - Free credits: yes
Request
{
"text": "Thanks for the quick reply, the new version works great.",
"images": [
{
"type": "url",
"url": "https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG"
}
]
}
Curl example:
curl -X POST https://www.chab.ai/v1/moderation/check \
-H "Authorization: Bearer CHAB_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: comment-check-001" \
-d '{"text":"Thanks for the quick reply, the new version works great.","images":[{"type":"url","url":"https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG"}]}'
Send text, images or both:
text: one text, or a list of 1 to 20 texts. Each text is up to 32,000 characters, and all together up to 100,000.images: a list of 1 to 4 images, each one of:{"type": "file_id", "id": "fil_..."}: a file you uploaded withPOST /v1/files.{"type": "artifact_id", "id": "art_..."}: an image another tool made, such as a screenshot or animages.generateimage.{"type": "url", "url": "https://..."}: a publichttpsimage. Chab downloads it (up to your plan's upload size) and checks it for viruses like an upload.
PNG, JPEG, WebP or HEIC. Chab turns each image upright and sends it at up to 2,000 pixels a side.
callback_url,callback_secret,callback_events, andcallback_notify_on_expiration: optional one-off operation callback fields.
Categories
Every verdict lists these 13 categories:
| Category | What it means | Reads |
|---|---|---|
harassment |
Harassing language towards someone | Text |
harassment_threatening |
Harassment that also threatens violence or serious harm | Text |
hate |
Hate based on race, gender, religion, nationality, disability or a similar trait | Text |
hate_threatening |
Hate that also threatens violence or serious harm | Text |
illicit |
Advice or instructions on how to do something illegal | Text |
illicit_violent |
The same, when it involves violence or weapons | Text |
self_harm |
Content that promotes or shows self-harm | Text and images |
self_harm_intent |
Someone says they intend to harm themselves | Text and images |
self_harm_instructions |
Instructions or advice on self-harm | Text and images |
sexual |
Sexual content | Text and images |
sexual_minors |
Sexual content that involves anyone under 18 | Text |
violence |
Content that shows or describes violence | Text and images |
violence_graphic |
Violence shown or described in graphic detail | Text and images |
For an image, the text-only categories have the score 0 and an empty
input_types list. A verdict is flagged when any of its categories is.
Scores are best used to rank or sort content for a person to review; the
flags are a reasonable default line.
Check Result
{
"data": {
"result": {
"flagged": false,
"flagged_categories": [],
"text_count": 1,
"image_count": 1,
"items": [
{
"type": "text",
"index": 0,
"characters": 56,
"flagged": false,
"flagged_categories": [],
"categories": {
"harassment": { "flagged": false, "score": 0.000015, "input_types": ["text"] },
"harassment_threatening": { "flagged": false, "score": 0.000002, "input_types": ["text"] },
"hate": { "flagged": false, "score": 0.000004, "input_types": ["text"] },
"illicit": { "flagged": false, "score": 0.000022, "input_types": ["text"] },
"sexual": { "flagged": false, "score": 0.000063, "input_types": ["text"] },
"violence": { "flagged": false, "score": 0.000016, "input_types": ["text"] }
}
},
{
"type": "image",
"index": 0,
"source": {
"type": "url",
"url": "https://upload.wikimedia.org/wikipedia/commons/4/45/A_small_cup_of_coffee.JPG",
"filename": "A_small_cup_of_coffee.JPG",
"format": "jpeg",
"byte_size": 401623
},
"flagged": false,
"flagged_categories": [],
"categories": {
"harassment": { "flagged": false, "score": 0, "input_types": [] },
"self_harm": { "flagged": false, "score": 0.000009, "input_types": ["image"] },
"sexual": { "flagged": false, "score": 0.000012, "input_types": ["image"] },
"violence": { "flagged": false, "score": 0.00002, "input_types": ["image"] }
}
}
]
},
"artifacts": [],
"warnings": [],
"result_expires_at": "2026-11-19T19:48:51+00:00"
},
"meta": {
"request_id": "req_123"
}
}
The categories are shortened here; each verdict lists all 13. This cost 1 credit.
Two texts in one check, "Great talk, thanks for sharing the slides!" and "Delete your post or I will find out where you live and make you regret it.", also cost 1 credit. The first came back clean. The second was flagged:
{
"type": "text",
"index": 1,
"characters": 75,
"flagged": true,
"flagged_categories": ["harassment", "harassment_threatening", "violence"],
"categories": {
"harassment": { "flagged": true, "score": 0.810283, "input_types": ["text"] },
"harassment_threatening": { "flagged": true, "score": 0.741277, "input_types": ["text"] },
"illicit": { "flagged": false, "score": 0.020101, "input_types": ["text"] },
"violence": { "flagged": true, "score": 0.354098, "input_types": ["text"] }
}
}
Moderation Errors
| Code | When | Charge |
|---|---|---|
validation_failed |
Neither text nor images, a text that is empty or too long, more than 20 texts or 4 images, or a URL that is not public https |
None |
not_found, file_expired, source_scan_pending, source_scan_failed |
An image file or artifact cannot be read | None |
unsupported_file_type |
An image is not PNG, JPEG, WebP or HEIC | None |
unsupported_file_content |
An image cannot be opened, or the model could not read the input | None |
source_too_large |
An image is larger than your plan's upload size | None |
source_quarantined |
An image did not pass the virus check | None |
target_fetch_blocked, target_timeout |
An image URL could not be downloaded | None |
provider_temporarily_rate_limited, provider_unavailable |
The moderation model is busy or cannot be reached right now; try again later | None |