Moderations
Checks text and images against content categories with a moderation model on your own worker. OpenAI-compatible.
Checks text or images with a moderation model on one of your workers, and says for each input whether it was flagged and in which categories. Use it to screen what users send, or what a model wrote before you show it.
It follows the OpenAI moderations format, so OpenAI clients work with a
Pendra base URL. It also answers at /api/v1/moderations.
Install a moderation model
Install one from the catalogue on a worker, like any other model. The content you send is checked on your own worker.
| Model | Checks | Good to know |
|---|---|---|
llama-guard3:1bllama-guard3:8b |
Text | The 8B catches more and flags less by mistake. The 1B is much faster. |
qwen3guard:0.6bqwen3guard:4bqwen3guard:8b |
Text, in many languages | Can answer borderline. Larger sizes catch more. |
singguard:0.8bsingguard:4b |
Text and images | The 4B catches more. The 0.8B suits small GPUs. |
model
string
Required
input
string | string[] | object[]
Required
- A string, for one result.
- Up to 32 strings, for one result each, in order.
- Up to 32
textandimage_urlparts, checked together for one result, so an image and its caption are judged as a whole.
Checking images
Send images as parts, to a model that checks images such as
singguard:4b:
{
"model": "singguard:4b",
"input": [
{ "type": "text", "text": "Profile photo for a new account" },
{ "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,/9j/4AAQ..." } }
]
}
A base64 data: URL always works. An https:// URL
works only if the worker's owner has turned on Allow remote image
URLs, as for images in chat.
Response
results has one entry per string, or one for a set of parts.
Each has:
flagged,trueif the model judged it unsafe.categories,truefor each category it falls into.-
category_scores, the same as numbers:1.0,0.0, or0.5for aqwen3guardborderline verdict, which still counts as flagged. category_applied_input_types, whether each category was judged ontext,imageor both.
Only the categories the model checks are included. A
missing category means the model doesn't check it, not that the content is
clean. The pendra field
names the worker that ran the check.
Categories
Pendra uses OpenAI's category names where one fits, and adds its own under
pendra/. Which ones each model checks:
| Category | llama-guard3 | qwen3guard | singguard |
|---|---|---|---|
harassment |
✓ | ✓ | ✓ |
hate |
✓ | ✓ | ✓ |
illicit |
✓ | ✓ | ✓ |
illicit/violent |
✓ | ✓ | No |
self-harm |
✓ | ✓ | ✓ |
sexual |
✓ | ✓ | ✓ |
sexual/minors |
✓ | No | No |
violence |
✓ | ✓ | ✓ |
pendra/cyber |
✓ | ✓ | No |
pendra/disinformation |
✓ | ✓ | ✓ |
pendra/fraud |
✓ | ✓ | ✓ |
pendra/intellectual_property |
✓ | ✓ | No |
pendra/nudity |
No | ✓ | ✓ |
pendra/privacy |
✓ | ✓ | No |
pendra/specialized_advice |
✓ | No | No |
pendra/unspecified |
✓ | ✓ | ✓ |
pendra/cyberis malware and intrusion,pendra/nudityincludes non-sexual nudity, andpendra/specialized_adviceis unqualified medical, legal or financial advice.pendra/unspecifiedmeans flagged without a named category.llama-guard3:1blistspendra/cyberbut never sets it. Only the 8B checks it.qwen3guardreports sexual content involving minors assexual, and a jailbreak attempt aspendra/unspecified.
Errors
Errors carry a code in error.code and the
X-Pendra-Error-Code header, so you can handle them without
reading the message. See Moderation
errors for every code. Also:
- Input longer than the model's context gets a
400with no code. Shorten or split it. - A malformed body, such as more than 32 inputs, gets a
422. -
A check that runs for more than about 80 seconds can
fail after a
200. Treat any response withoutresultsas not checked.
End-to-end encryption
With end-to-end encryption turned on in the Pendra SDK, your worker reads the content and encrypts the verdict back to you, so Pendra sees neither. It needs Python SDK 0.19.0 or Node SDK 0.18.0 or later, and a recent worker.
To check encrypted chat automatically instead, turn on content filtering for the API key.
Try it in the Playground
Open Moderation mode in the Playground, then paste text or attach an image to see each category's verdict.
Good to know
- The endpoint only returns verdicts. It never blocks anything, so what to do with flagged content is up to you. A model can miss harmful content or flag harmless content, so treat it as one signal.
-
The usage log records each check's
outcome (
pass,flaggedorerror) and flagged categories, never the content. An encrypted check records no verdict. -
Each string in an array is checked one after another, so 32 strings take
about 32 times as long as one. A small model such as
llama-guard3:1busually answers in well under a second. - A check can wait behind a long chat reply on the same worker. If you check every request, put the moderation model on a less busy worker.
- To use one particular worker, send the
X-Pendra-Worker-Idheader.