Describe what OpenAI's Moderation API classifies and what it does not
OpenAI's Moderation API is a free content-category classifier over OpenAI's policy taxonomy; it does not detect prompt injection, PII, secrets, off-topic content, or your custom policy.
Imagine the Moderation API as a smoke alarm tuned to one company's idea of dangerous smoke. It will beep loudly when it smells the things on its list, like harassment or violent threats, and it will tell you which kind of smoke it noticed. It does not care about the smell of someone whispering instructions to a robot to misbehave, it does not notice if a phone number has just floated past, and it does not know whether your house has a rule about no candles in the bedroom. The alarm is genuinely useful for what it covers, but it covers a narrow set of smells. You still need other alarms for everything else, and you have to install them yourself.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
The OpenAI Moderation API has been the default first stop for content safety in OpenAI-backed applications since GPT-3 launched. It is free, it is fast, and it is well-aligned with OpenAI's own model behaviour. Those properties also encourage a recurring mistake: treating it as the general-purpose safety layer for the application.
This card describes what the API actually does, then walks through three categories it explicitly does not cover, then sketches the layered architecture that uses it correctly. The aim is to make you fluent enough to defend the layer's role to a skeptical interviewer or to a security review.
What the Moderation API actually returns
The Moderation API is a classifier with a well-defined output shape. Send it text (and, in the omni-moderation model, optionally an image), receive back:
- A per-category numerical score from 0 to 1 across categories like harassment, hate, self-harm, sexual content, violence, illicit, plus a few sub-categories such as harassment/threatening and self-harm/intent.
- A per-category boolean flag indicating whether the score crossed OpenAI's threshold.
- A top-level flagged boolean that is the disjunction of the per-category flags.
Why both scores and flags
The flags are a convenience for the simple case of refuse if any category tripped. The scores are the operating-point control. A consumer-product team might decide that any score above 0.3 on harassment is unacceptable for their family-friendly audience; an enterprise legal tool might accept a higher threshold because the cost of false positives is also high. The scores let you tune.
Cost and latency
The API is free at time of writing; the omni-moderation model adds image input and improved multilingual coverage at the same price point. Latency is in the tens of milliseconds, comparable to a small embedding call, so it fits inline in both input and output rails.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- OpenAI's omni moderation latest (released late 2024) added image input and improved multilingual coverage; teams running GPT-5.5 chat experiences typically still pair it with a separate injection rail.
- Lakera Guard and Microsoft Presidio are commonly stacked alongside the Moderation API in production OpenAI deployments precisely because the Moderation taxonomy does not cover injection or PII.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow do you choose the per-category threshold to use instead of the default boolean?
Build a labelled adversarial dataset for your application, sweep thresholds, and pick the operating point where your false-positive cost equals your false-negative cost.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Treating Moderation API as a general-purpose safety gate; it is a content-category classifier and misses injection, PII, secrets, off-topic, and any custom policy you care about.
60 second bullets to scan on the way to the call.
What categories the Moderation API returns
Score vector versus boolean flags and how to choose thresholds
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.