The OpenAI Moderation API is a free classifier that tells you whether a piece of text or an image is likely to contain harmful content. If your application accepts user-generated input, whether that is a chatbot, a comment box, a support form, or an image upload, a moderation check is one of the cheapest safety layers you can add. This guide explains what the endpoint does, how to read its results, how to choose thresholds, and where moderation stops and other safeguards need to begin.
What the Moderation API Is
The moderation endpoint takes content and returns a classification for a set of harm categories, with a yes or no flag for each and a confidence score between 0 and 1. It does not generate text and it does not block anything by itself. It gives you information, and your application decides what to do with it: allow the content, hide it, ask the user to rephrase, send it to a human reviewer, or reject it. The current model, omni-moderation-latest, accepts text and images, does not classify audio, and is free to use, with rate limits that depend on your usage tier. It replaced the older text-only moderation model, which remains available for legacy integrations but cannot assess images.
What It Covers
The categories are grouped by type of harm. They include harassment and threatening harassment, hate and threatening hate, illicit content and violent illicit content, self-harm in its general, intent, and instruction forms, sexual content and sexual content involving minors, and violence and graphic violence. Each result lists, for every category, whether it was flagged and its numeric score, plus a field showing which input types each category was actually applied to. That last field matters for images, as explained below.
Figure 1 — What a moderation result contains
Making a Request
With the official library, call the moderations create method with the model name omni-moderation-latest and an input. The input can be a single string, a list of strings for batching several texts in one call, or a list of multimodal items that mix text and image entries, where an image is supplied as a URL or as base64 data. The response returns one result per input. Batch where you can, since it saves round trips and reduces your exposure to rate limits.
Reading the Results
Start with the flagged field for a simple decision, then look deeper when you need control. The category scores let you set your own thresholds rather than accepting the default. A children’s education product might block at a score of 0.2 for sexual or violent content, while an adult fiction community might tolerate far higher violence scores but still apply a strict threshold to threats and to anything involving minors. Log the scores for flagged and borderline content so that you can examine them later and tune thresholds against real cases instead of guessing.
How Images Are Handled
Image moderation is category-specific. Only some categories apply to images, broadly the violence, self-harm, and sexual groups, and the category_applied_input_types field in the response tells you exactly which inputs each category used. If you send an image with no accompanying text, the categories that only work on text return a score of zero, which does not mean the image is clean for those categories. Images are limited to 20 megabytes. When an image arrives with a caption or message, send both together as a multimodal input so the model can consider them in combination, rather than moderating each separately.
Where to Put Moderation in Your Flow
There are three common patterns. Input moderation checks what the user submits before you spend money on a model call, and lets you refuse or reroute harmful requests cheaply. Output moderation checks what the model produced before you show it to the user, a useful backstop for an application that must never display certain content. Combined moderation does both. OpenAI has also added the option to request moderation results alongside a generation in the Responses and Chat Completions APIs by setting a moderation model on the request, which returns input and output results in the response object. That is convenient and can reduce the extra network call, but check the current documentation for how errors are reported and whether it fits your latency and logging needs.
For streaming chat, output moderation is harder, because text appears as it is generated. A common compromise is to buffer a sentence or paragraph, moderate it, and only then release it to the user, accepting a small delay in return for safety.
Choosing a Policy for Flagged Content
Decide in advance what happens in each case, because the right response differs. For clearly harmful input in a chatbot, a calm refusal with a pointer to appropriate help is usually better than silence. For user-generated posts, hiding content pending review and notifying the author is common. For borderline scores, route to a human reviewer rather than automatically punishing the user. For content involving self-harm, a supportive message with local crisis resources is more appropriate than a simple block. Write the policy down, test it with sample inputs, and make sure users have a way to appeal mistaken decisions.
Human Review and Measurement
No classifier is perfect. It will flag some harmless content, and it will miss some harmful content, particularly sarcasm, coded language, and context that depends on a conversation rather than a single message. Build a small labelled sample of your own traffic, run it through the endpoint, and measure how many harmful items it catches and how many harmless items it wrongly flags at each threshold. Review a random sample of both flagged and unflagged content regularly, and track the trend. If your product has serious safety obligations, treat moderation scores as one input to a process that includes human review, not as the final decision.
What Moderation Does Not Do
The moderation endpoint classifies harmful content categories. It does not detect prompt injection, protect you from jailbreaks, find personal data, verify facts, or check that an answer is on topic. Those need separate controls: input and output validation, privacy filters, retrieval grounding, restricted tool permissions, and application-level checks. If you need a self-hosted safety classifier, for example because content cannot leave your network, open models such as Llama Guard or ShieldGemma can be run locally, with the usual trade-off that you own the hosting, tuning, and evaluation.
Privacy, Latency, and Reliability
Moderating content means sending it to OpenAI, so reflect that in your privacy notice and check that it fits your data-handling obligations. Moderation calls are fast relative to generation, but they still add latency, so run them in parallel with other work where possible and cache results for identical content. Because the endpoint is rate limited by tier, handle rate-limit responses with retries and backoff. Decide whether your application fails open or fails closed if the moderation service is unavailable: a children’s product may need to block until moderation succeeds, while a low-risk tool may continue and log the gap for review.
Common Mistakes
- Treating flagged as the whole story. Use scores and your own thresholds for finer control.
- Assuming images are fully covered. Text-only categories score zero on image-only input.
- Moderating only input. A model can still produce something you do not want to show.
- No appeal path. False positives will happen, so give users a way to contest them.
- Relying on it for security. It will not stop prompt injection or data leaks.
- Never reviewing results. Sample flagged and unflagged content to catch drift and blind spots.
Frequently Asked Questions
- Is the OpenAI Moderation API free?
- Yes. OpenAI makes the moderation endpoint free to use for developers, with rate limits that depend on your usage tier. You still need an API key.
- Does it moderate audio?
- No. The current model handles text and images. For audio, transcribe it first and moderate the transcript.
- Which model should I use?
- Use omni-moderation-latest for new work. The older text-only model is mainly for existing integrations.
- Can I change the thresholds?
- Yes. Use the category scores and apply your own thresholds per category instead of relying only on the flagged field.
Last updated: November 2026. Categories, models, and limits change, so confirm details in OpenAI’s moderation guide.
A Simple Moderation Workflow for a Chatbot
To make this concrete, consider a customer-facing chatbot. When a message arrives, send it to the moderation endpoint first. If nothing is flagged and no score approaches your thresholds, pass the message to the language model as normal. If a category crosses a high threshold, skip the model call entirely and return a short, polite message explaining that you cannot help with that request, and log the event with the scores. If the score falls in a middle band, let the model respond but add the conversation to a review queue so a person can check it later. After the model replies, run the answer through moderation before displaying it, and replace it with a safe fallback message if it is flagged. Keep the whole decision logic in one small function with the thresholds stored in configuration, so you can adjust them without redeploying. Test the function with a file of example messages that covers harmless, borderline, and clearly harmful cases, and rerun that file every time you change a threshold or switch models, so that a tuning change in one direction does not quietly break the other.
It also helps to keep a simple dashboard of how many messages are flagged each day and in which categories. A sudden rise usually means either an abuse campaign or a bug, and either way you want to notice it quickly rather than discover it from a user complaint.