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."
  }'

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 }
    }
  ]
}
FieldMeaning
flaggedtrue if any category matched. Check this first.
categoriesMap of category name to a boolean: whether that category matched.
category_scoresMap 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

Was this page helpful?