How to Add Automated Moderation to Your App (Step-by-Step Guide)

Six steps, with working Node and Python code.
How to Add Automated Moderation to Your App (Step-by-Step Guide)

To add automated moderation to an app, decide what content to check and when, write a policy, choose an approach, and enforce its keep, flag, or remove result in your code. Send flagged items to a human review queue with appeals, and measure results to tune thresholds.

Stream Moderation does this through one API: it checks text, images, audio, video, and live streams against 35+ harm categories in 50+ languages

The steps below work with any vendor or system you build yourself. We’ll use Stream as the example, with working code in Node and Python.

Step 1: Decide What to Moderate and When

First, you'll want to list every place users can add content, then decide which ones get checked and at what point. This sets the scope for everything you'll read next.

Start with an inventory. For each place, note the content type, how much of it you expect, and how bad a miss would be.

  • Text: chat messages, comments, posts, reviews, listing descriptions.
  • Profile data: usernames, bios, profile photos.
  • Images: uploads in chat, listings, or feeds.
  • Audio and video: voice notes, uploaded videos, and live streams.

Then pick a timing for each one:

  • Pre-send: check the content before anyone else sees it. Use it where one bad item causes real harm, such as apps with minors or public posts.
  • Post-send: show the content right away and check it a moment later. Use it for fast, high-volume text where delay hurts the experience.
  • Both: run a fast check before sending and a deeper check after.

The pre-send vs. post-moderation section below covers the trade-offs in more detail.

Step 2: Write a Moderation Policy

A moderation policy is a short document that says what is allowed, what is not, and what happens when someone breaks the rule. You should write it before you pick a tool, so the tool follows your rules and not the other way around.

A useful policy has four parts:

  1. Harm categories. Name each type of content you will act on, for example harassment, hate speech, spam, scams, sexual content, violence, and personal data. Give each one a plain-language definition and two or three examples.
  2. Severity. Decide what separates a mild case from a serious one. Rude banter between friends is not the same as a threat.
  3. An action per category and severity. Pick keep, flag, or remove for each. A common split is to remove clear violations and flag borderline cases for a person to review.
  4. Context about your app. Say who your users are and what is normal. Trash talk is fine in a gaming chat and not in a classroom app.

Keep the policy in version control or a shared doc. You will change it often, and you will need the history if a user appeals or a regulator asks how you decide.

Step 3: Choose an Approach

Pick the simplest approach that covers your policy, and mix approaches when one is not enough. There are four common choices.

  • Filters (blocklists and regex). Match words, phrases, or patterns. Filters are fast, cheap, and easy to explain. People get around them with misspellings, and they cannot read context.
  • Rules. Run an action when conditions are met, such as banning a user after three flagged messages in an hour. Rules look at behavior over time instead of a single message. You set the thresholds, and you will need to tune them as your users change.
  • Machine learning classifiers. Models trained on labeled data return a score for each harm category. They handle more variety than rules and run quickly. You choose the score threshold for each action.
  • LLMs. A large language model reads the message with the rest of the conversation and your written rules. It handles context, sarcasm and intent better, and costs more per check.
  • An API that combines them. A moderation API bundles rules, classifiers, and often an LLM behind one call, and may add a review queue. You trade some control for much less to build and maintain.

Moderation Options Compared

The table compares the four ways most teams start, including building filters yourself, using cloud APIs from Google Gemini or Azure, or using Stream.

Option Content types Latency Pricing Review queue included
DIY filters (blocklists, regex) Text, plus whatever you build for other types Runs in your own code, so no network call No per-request fee. You pay in engineering and maintenance time No. You build it
Google Gemini API (Gemini 3.1 Flash-Lite) Text, images, video, and audio. You write the prompt and the labels Not published as a benchmark. Test in your region Billed per token, not per item. $0.25 per 1M input tokens for text, images, and video, $0.50 per 1M for audio, and $1.50 per 1M output tokens No. You build it
Azure AI Content Safety Text and images Not published as a benchmark. Test in your region Free tier of 5,000 text records and 5,000 images per month. Standard tier is billed per 1,000 text records and per 1,000 images No. You build it
Stream Moderation Text, images, audio, video, and live video English text: about 35 ms median, about 70 ms at p95 Text $2.00 per 1,000. Images $4.00 per 1,000. Video $0.80 per minute. Audio $0.06 per minute. $100 in free credits each month; enterprise discounts up to 75% off Yes, with appeals and a moderator dashboard

Prices checked on each vendor’s website in November 2026 and are subject to change.

How to read this: Cloud APIs are usually cheaper per request, but you add the policy logic, the review queue, and the appeals flow yourself. Stream costs more per request and includes those parts, plus an LLM engine that reads context, with enterprise discounts up to 75%. Which is cheaper in total depends on how much you would otherwise build.

What Is the Best Moderation API?

The best moderation API is the one that covers your content types, meets your latency needs, and fits the staff you have to run it. Ask five questions when you compare:

  1. Does it cover every content type in your inventory from Step 1?
  2. Can you set your own categories, severities, and actions, or only use fixed ones?
  3. How fast is it on your send path, measured at p95 and not only the average?
  4. Does it include a review queue and appeals, or do you build them?
  5. How does the price change as volume grows, and is there a free tier to test with?

A team that already uses Gemini and wants to write its own labels and prompts may do fine with it. A team that needs text, images, and review in one place, with no separate queue to build, would benefit the most from Stream.

Step 4: Handle Keep, Flag, and Remove, and Decide What the User Sees

The moderation system returns a recommendation, and your code enforces it. You should decide in advance what each result does to the content and what the author is told.

Most systems return one of three results, and some add a few more:

Result What your app does What the author sees
Keep Publish the content Nothing. The post goes through
Flag Publish it, or hold it, and add it to the review queue Usually nothing, until a reviewer decides
Remove Do not publish it, and keep a copy for audit and appeals A clear notice that it was removed, with a way to appeal

Some APIs also support hiding content from everyone except its author (often called a shadow action) and rejecting a message before it is published (a bounce). Use a bounce when you want to ask the sender to rewrite the message. Use a shadow action for spam and abuse from repeat offenders, where a visible block would only teach them to adapt. Stream supports all of these actions. Your policy sets the action for each category, and the check response returns keep, flag, remove, shadow, or bounce for your code to enforce.

Write the message the user sees with care:

  • Say what happened in one sentence, and name the rule when you can.
  • Offer a next step: edit and resend, or appeal.
  • Keep the tone neutral. The user may have done nothing wrong, because no automated system is perfect.

Always keep removed content, the policy version, and the decision. You need that record for appeals, audits, and tuning in Step 6.

Step 5: Route Flagged Items to a Human Review Queue With Appeals

Automated checks will make mistakes, so give people a place to review borderline items and a way for users to challenge decisions. This is what keeps automated moderation fair.

A review queue needs a few basics:

  • A list of flagged and removed items, with the content, the rule that matched, and the author's history.
  • Actions for moderators: approve, remove, warn, mute, or ban.
  • Sorting by severity and age, so the worst items and the oldest items are seen first.
  • A decision log that records who decided what, and when.

Appeals need three more things: 1) a way for the author to submit a short reason, 2) a moderator who was not involved in the first decision, 3) and a written answer sent back to the user.

If you build this yourself, plan for a queue table, a moderator interface, roles and permissions, and an appeals flow. Many teams find this is more work than the detection step. Some APIs, including Stream's, provide the queue and appeals so you do not have to build them.

Stream also includes Nora, an AI moderation agent that reviews flags for you. For each flag, Nora checks the conversation, the user’s history, the actions already taken, and your policy. It then takes action or recommends one for a moderator to confirm. Fewer flags reach a person, so moderators spend their time on borderline cases and appeals.

In Stream, flagged and removed items go to the review queue in the dashboard automatically. A user can appeal removed content or a ban with a reason of up to 500 characters and up to 10 attachments. A moderator then restores the content or rejects the appeal, and can add a reason that the user sees:

await client.moderation.appeal({
  appeal_reason: "I believe my message was wrongfully blocked",
  entity_id: "message-123",
  entity_type: "stream:chat:v1:message",
  user_id: "user-456",
});

See the appeals docs and the review queue docs for the full flow.

Step 6: Measure Results and Tune Your Thresholds

Track a few numbers from the first day, then adjust your rules and thresholds on a regular schedule. Generally, the first policy you write will not be the right one.

Watch these measures:

  • Precision: of the items the system acted on, how many were truly violations. Low precision means you are blocking good content.
  • Recall: of all real violations, how many the system caught. Low recall means harm is getting through.
  • Appeal overturn rate: how often moderators reverse a decision after an appeal. A high rate points to a rule or threshold that is too strict.
  • Time to review: how long flagged items wait in the queue.
  • Flag volume: the share of content that reaches human review. If it is too high, your moderators cannot keep up.

To tune, build a test set of real examples from your app, with the correct answer for each. Run the policy against it, change one thing, and run it again. Look closely at languages, slang, and edge cases that matter to your users, because accuracy is usually lowest there. Stream's Evaluations feature is built for this kind of testing before you turn on automatic actions.

A practical way to start is to flag borderline cases for review at first, and move them to automatic removal only when reviewers agree with the system almost every time.

Worked Example: Add Moderation With the Stream API

With Stream, you install an SDK on your server, create a policy, send content to the check endpoint, and act on the result. This example follows the current getting started guide. You need a Stream account, and an API key and secret from the dashboard. Each month starts with $100 in free moderation credits.

1. Install the SDK and Create a Client

Node.js:

npm install @stream-io/node-sdk
import { StreamClient } from "@stream-io/node-sdk";

const client = new StreamClient("YOUR_API_KEY", "YOUR_API_SECRET");

Python:

pip install getstream
from getstream import Stream

client = Stream(api_key="YOUR_API_KEY", api_secret="YOUR_API_SECRET")
Get started! Activate your free Stream account today and start prototyping with moderation.

2. Create a Moderation Policy

The policy turns the decisions from Steps 2 and 4 into rules. This one flags spam, removes hateful content, and removes anything that matches an English profanity blocklist.

Node.js:

await client.moderation.upsertConfig({
  key: "my_config",
  ai_text_config: {
    rules: [
      { label: "SPAM", action: "flag" },
      { label: "HATRED", action: "remove" },
    ],
  },
  block_list_config: {
    rules: [{ name: "profanity_en", action: "remove" }],
  },
});

Python:

client.moderation.upsert_config(
    key="my_config",
    ai_text_config={
        "rules": [
            {"label": "SPAM", "action": "flag"},
            {"label": "HATRED", "action": "remove"},
        ],
    },
    block_list_config={
        "rules": [{"name": "profanity_en", "action": "remove"}],
    },
)

If you want an LLM to read messages in context against rules you write in plain language, use the LLM text engine in the same policy.

3. Check Content

Send each piece of content with an ID for the item, an ID for its author, and your policy key.

Node.js:

const response = await client.moderation.check({
  entity_type: "post",
  entity_id: "post-123",
  entity_creator_id: "user-456",
  moderation_payload: {
    texts: ["Selling a bike, pickup in the city"],
  },
  config_key: "my_config",
});

console.log(response.recommended_action);

Python:

from getstream.models import ModerationPayload

response = client.moderation().check(
    entity_type="stream:chat:v1:message",
    entity_id="message-123",
    entity_creator_id="user-456",
    moderation_payload=ModerationPayload(
        texts=["Hello, this is a test message"],
    ),
    config_key="my_config",
)

print(response.data.recommended_action)

4. Handle the Result

The response has a recommended_action for your code to enforce, a status that shows whether any slower checks are still running, and an item for the review queue when the action is not keep.

See the appeals docs, and the review queue docs for the full flow.

if (response.recommended_action === "keep") {
  // Publish the content
} else if (response.recommended_action === "flag") {
  // Publish it, and review the queued item
  console.log("Flagged for review:", response.item);
} else if (response.recommended_action === "shadow") {
  // Show it only to the author
} else if (
  response.recommended_action === "remove" ||
  response.recommended_action === "bounce" ||
  response.recommended_action === "bounce_remove"
) {
  // Do not publish it. Removed items stay in the review queue.
  console.log("Not published:", response.item);
}

Flagged and removed items now appear in the review queue in the Stream dashboard, where moderators can approve, delete, or ban, and where appeals are handled.

action = response.data.recommended_action

if action == "keep":
    # Content is safe, no action needed
    pass
elif action == "flag":
    # Content is suspicious; Stream has queued it for review
    print("Flagged for review:", response.data.item)
elif action == "remove":
    # Content violates policies, remove it
    print("Content removed:", response.data.item)

No-Code Path: Apps Already on Stream Chat or Feeds

If your app already uses Stream Chat or Feeds, you do not need to call the check endpoint. You set the policy once, and Stream moderates content as it is created.

  • Chat: create a policy with the key chat:messaging in the dashboard, or through the API. The Chat UI SDKs apply it to messages automatically, with no client code. You can also set a policy for one channel (chat:messaging:channel_id) or for all chat channels (chat).
  • Feeds: use the policy key feeds. Activities and comments are moderated when they are created or updated.
  • Messages sent from your server: these skip moderation by default. Set force_moderation to true on the send call to include them.

See the Stream Chat integration and Stream Feeds integration docs for details.

Moderation API Pricing

Moderation APIs charge per item checked, usually per 1,000 texts or images and per minute of audio or video, so cost grows with volume. Check what counts as one unit, because some APIs bill by character length and others by request.

Stream's pay-as-you-go prices from its pricing page:

Content Price
Text $2.00 per 1,000
Images $4.00 per 1,000
Images with CSAM detection $6.00 per 1,000
Images with OCR $7.60 per 1,000
Images with OCR and CSAM detection $10.00 per 1,000
Video files $0.80 per minute
Live video $4.00 per 1,000 frames
Audio $0.06 per minute

Prices checked November 2026 and subject to change.

Every account gets $100 in free credits each month, covering text, images, video, and audio, and no credit card is needed to start. For example, 1,000,000 text messages a month is $2,000 at list price before the free credits. Enterprise plans use a yearly volume commitment and list discounts of up to 75% at scale.

When you compare prices, include the cost of what is not in the price. A cheaper API that returns only scores still needs a review queue, an appeals flow, and a policy interface built around it.

Pre-Send vs. Post-Moderation

Pre-send moderation checks content before anyone else sees it, and post-moderation shows it first and checks it afterward. Pre-send is safer, and post-moderation feels faster.

Pre-send Post-send
When the check runs Before the content is published After the content is published
Harm that gets through None, if the check is right Visible until the check finishes
Delay for the sender Adds the check time to every message None
Best for Apps with minors, public posts, anything where one miss is costly High-volume chat, large files, deeper checks

Speed decides most cases. With English text taking about 35 ms at the median and about 70 ms at p95 in Stream's published numbers, a pre-send check on short messages is hard to notice. Slower content is different. Stream accepts video and audio files, then scores them in the background, so those use post-moderation by design.

Many apps combine both. They check text before sending, check images and video as they are published, and remove content afterward if a deeper check disagrees. With Stream's API, the status field tells you whether slower checks are still running.

How to Moderate Images in Chat

To moderate images in chat, send each image to an image moderation model before or as it is posted, and apply the same keep, flag, or remove rules you use for text. Images need their own policy categories, such as nudity, violence, and weapons.

Image checks take longer than text checks. In Stream's published numbers, the API responds in about 40 ms, and scoring a photo takes about 300 ms. Decide whether chat images are held until they pass or shown first and checked after, as in the pre-send section above.

If you use Stream Chat, image attachments are checked by the same chat policy as text, and the moderation result lists image labels such as nudity or violence. If you send images yourself, add them to the same check call:

const response = await client.moderation.check({
  entity_type: "post",
  entity_id: "post-124",
  entity_creator_id: "user-456",
  moderation_payload: {
    texts: ["Check out my new bike"],
    images: ["https://example.com/bike.jpg"],
  },
  config_key: "my_config",
});

Image moderation costs more than text. Plan for it in your budget, and add CSAM detection and OCR (to read text inside images) if your risk profile calls for them.

Frequently Asked Questions

How much does automated moderation cost?

Costs depend on volume and content type. At Stream's pay-as-you-go rates, text is $2.00 per 1,000 messages and images are $4.00 per 1,000, with $100 in free credits each month. Enterprise plans are up to 75% off list rates. Cloud APIs from Google Gemini and Azure often charge less per request but leave the review queue and appeals to you. See Moderation API pricing above.

Are there free moderation APIs?

Yes, with limits. Stream gives $100 in free moderation credits each month. Azure AI Content Safety has a free tier of 5,000 text records and 5,000 images per month. OpenAI's moderation endpoint has been free to use. Check each provider's current terms, because free tiers change, and check whether they include a review queue.

How fast is automated moderation?

English text on Stream's chat and feeds send path takes about 35 ms at the median, about 70 ms at p95, and about 100 ms at p99. Images get an API response in about 40 ms, and scoring a photo takes about 300 ms. Video and audio files are scored in the background.

Can automated moderation handle images and video?

Yes. Image models check photos and profile pictures. For video files, the API accepts the upload and scores it in the background. For live video, your app samples keyframes and sends them as images. Audio is transcribed and then checked with the same text engines. Stream prices video at $0.80 per minute and live video at $4.00 per 1,000 frames.

Do I need Stream Chat to use Stream Moderation?

No. The check API works for any content from your own app, such as posts, listings, comments, and usernames. If you do use Stream Chat or Feeds, moderation connects with no code changes, as shown in the no-code path above.

What does the Digital Services Act require?

The EU Digital Services Act (DSA) puts duties on online platforms that host user content. Among them are a way for people to report illegal content, a clear explanation to users when you remove their content or restrict their account, and a free internal complaint process to challenge those decisions. Some duties are lighter for micro and small businesses. A removal notice (Step 4) and an appeals flow (Step 5) cover much of the practical work, but this is not legal advice, so ask your counsel which rules apply to you.