ToolsModeration - BevvyTech/BrewskiDocs GitHub Wiki

Tools – Moderation Testing

Overview

  • Endpoint Group: Tools / Diagnostics
  • Purpose: Run ad-hoc moderation checks against OpenAI text and Gemini image classifiers.
  • Availability: Requires membership of the internal super user team.

Endpoint Summary

Method Path Description
POST /tools/moderation/evaluate Submit text and/or image content for moderation.

Authentication

  • Authorization: Bearer <token> — caller must belong to a team with role = 'su'. Other users receive 403 Forbidden.

Request

POST /tools/moderation/evaluate

Body

{
  "text": "New label copy for review…",
  "image": {
    "base64": "<base64-encoded image payload>",
    "mime": "image/png"
  }
}
  • text (string, optional) — text to evaluate via omni-moderation-latest.
  • image (object, optional) — data URI payload for Gemini Flash-Lite image moderation.
    • base64 (string, required) — Base64-encoded image bytes.
    • mime (string, optional) — MIME type, defaults to image/png.

At least one of text or image must be supplied.

Response

Success 200 OK

{
  "result": {
    "results": [
      {
        "flagged": false,
        "categories": {
          "sexual": false,
          "violence": true,
          "hate": false,
          "self-harm": false,
          "harassment/threatening": false
        },
        "confidence": {
          "sexual": 0.11,
          "violence": 0.86,
          "hate": 0.04,
          "self-harm": 0.02,
          "harassment/threatening": 0.05
        }
      }
    ]
  },
  "checked": {
    "text": true,
    "image": true
  }
}
  • result.results matches the OpenAI moderation schema and includes combined text/image outcomes.
  • confidence carries provider scores (0.0–1.0) for each category.
  • checked indicates which content types were evaluated for this request.

Error Codes

Status Body Example When It Happens
400 Bad Request { "message": "Invalid request", "issues": { … } } Payload failed validation (neither text nor image provided, malformed image, etc.).
401 Unauthorized { "message": "Unauthorized" } Missing or invalid bearer token.
403 Forbidden { "message": "Forbidden" } Caller is not a super user.
502 Bad Gateway { "message": "Moderation providers are unavailable", "detail": "…" } Upstream moderation provider returned an error or timed out.
⚠️ **GitHub.com Fallback** ⚠️