Moderations
Classify text against content-safety categories with the cruxy-guard model.
POST /api/v1/moderations checks text against the content-safety
categories and returns whether each one matched, plus an overall
flagged. It is OpenAI-compatible. Here is a single-string check:
curl https://api.cruxy.ai/api/v1/moderations \
-H "Authorization: Bearer $CRUXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cruxy-guard",
"input": "I want to learn how to bake bread."
}'const res = await fetch('https://api.cruxy.ai/api/v1/moderations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CRUXY_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'cruxy-guard',
input: 'I want to learn how to bake bread.',
}),
})
const { results } = await res.json()
if (results[0].flagged) {
// handle flagged content
}The model
model must be "cruxy-guard". It is the only moderation model on the
gateway.
Single string or array
input accepts a single string or an array of strings. With an array,
results holds one entry per input, in order.
Response shape
{
"id": "modr-a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"model": "cruxy-guard",
"results": [
{
"flagged": false,
"categories": { "example_category": false },
"category_scores": { "example_category": 0.0 }
}
]
}| Field | Meaning |
|---|---|
flagged | true if any category matched. Check this first. |
categories | Map of category name to a boolean: whether that category matched. |
category_scores | Map of category name to a score. See the caveat below. |
categories and category_scores share the same keys, one per
moderation category. The keys shown above are illustrative; treat the
category set as whatever the response returns rather than a fixed list.
category_scores is binary
The scores are not calibrated probabilities. The guard model emits
labels, not likelihoods, so each value in category_scores is either
1.0 or 0.0, the same information as the boolean in categories,
expressed as a number. Do not threshold these scores or read them as
confidence. To decide whether to act, use flagged (or the per-category
booleans in categories). To run this check in front of a chat call, see
the Moderation gate recipe.
Errors
Moderations returns 400 for a malformed request, 401 for a bad key,
and 429 for rate_limited or budget_exhausted. See
Errors.
Next steps
- Moderation gate: screen input before it reaches chat.
- Chat: completions across the tiers.
- Errors: the error shape.