AI

Content Moderation for Generative AI: Practical Implementation

Practical content moderation for generative AI, with input safeguards, output controls, and EU AI Act checks that reduce risk without blocking value today.

Halden Solutions20 Aug 20269 min read

Start with a conversation

Talk to us

Use Halden AI as a sales assistant to explore services, understand offerings, and choose the right next step before booking a meeting.

Book a Meeting

Content moderation is a critical safety layer for generative AI systems. Unlike moderation on a social platform, where the concern is mostly user-submitted content, a generative AI product has two moderation surfaces: what users submit as prompts, and what the model generates in response. A system that only checks one side will still ship harmful output.

In short:

Practical generative AI content moderation combines a fast, cheap classifier pass on both input and output (catching hate, violence, self-harm, sexual content, and similar categories) with narrower, task-specific checks for your domain, and an escalation path for anything the classifier is unsure about. Off-the-shelf classifiers such as OpenAI's Moderation API and Azure AI Content Safety handle the general categories and, on Azure, prompt-injection detection specifically; neither replaces domain-specific policy enforcement, human review for edge cases, or the labeling obligations now required under the EU AI Act for synthetic and AI-generated content.

Key Takeaways

  • Moderate both directions. Input moderation stops abusive or manipulative prompts from reaching the model; output moderation catches harmful, false, or out-of-policy generations before they reach the user. Both are needed.
  • General-purpose classifiers cover common harm categories, not your product's specific policies. A classifier trained on hate speech or sexual content won't know your company's specific rules about, say, medical claims or competitor mentions — that requires custom checks.
  • Confidence, not just pass/fail, should route decisions. Low-confidence classifications belong in a human review queue, not an automatic block or an automatic pass.
  • Labeling is now a legal requirement in the EU for a wide range of generative outputs. Article 50 of the EU AI Act requires machine-readable marking of synthetic audio, image, video, and text, and clear labeling of deepfakes and AI-generated text on public-interest topics, applicable from 2 August 2026.
  • Prompt injection is a distinct threat from harmful-content generation, and needs its own detection layer — Azure AI Content Safety's Prompt Shields, for example, is purpose-built to catch both direct jailbreak attempts and indirect injection hidden inside documents the model is asked to process.
  • Moderation adds latency and cost that must be budgeted for, particularly for multimodal (image/video) checks, which are typically slower and more expensive than text-only classification.

What Does Content Moderation Actually Need to Cover?

Diagram showing a generative AI moderation pipeline: input moderation before the model call, output moderation after it, and domain-specific policy checks running in parallel, before a response reaches the user

Input moderation

The first check happens before a prompt ever reaches the generative model: is this request itself abusive, an attempt to extract disallowed content, or a manipulation attempt (prompt injection, jailbreak phrasing)? This is a cheaper, faster check than generating a full response first and moderating after the fact, and it stops wasted inference cost on requests that should never be answered.

Prompt injection specifically deserves its own detection layer rather than being folded into general harm-category classification. Azure AI Content Safety's Prompt Shields, for example, is a dedicated API that detects both direct attacks — a user directly attempting to override system instructions, embed fake conversation turns, or use encoding tricks (base64, character substitution) to smuggle disallowed requests past a filter — and indirect attacks, where malicious instructions are hidden inside a document, webpage, or other content the model is asked to process on the user's behalf, aiming to exfiltrate data, manipulate output, or gain unauthorized system access (Microsoft Learn — Prompt Shields in Azure AI Content Safety). Indirect injection is easy to overlook in a moderation design focused only on what the user typed, since the attack payload arrives through retrieved content rather than the prompt box.

Output moderation

The second check happens on what the model actually produced. Even a well-instructed model can generate harmful content, especially under adversarial prompting, so output moderation is not optional even if input moderation is strong. General-purpose moderation classifiers, such as OpenAI's omni-moderation-latest model, evaluate text and, for certain categories, images against categories including hate, violence, self-harm, sexual content, and illicit content, and are offered free of charge through OpenAI's Moderation API with usage-tier-based rate limits (OpenAI). Multimodal support currently covers violence, self-harm, and sexual content for images, with OpenAI stating it is working to expand multimodal coverage to additional categories.

Azure AI Content Safety takes a similar category-based approach but adds an explicit severity dimension: text and multimodal content is scored on a 0–7 scale (commonly trimmed to 0, 2, 4, 6) across four harm categories — Hate and Fairness, Sexual, Violence, and Self-Harm — with content able to receive multiple category flags at once (Microsoft Learn — Harm categories in Azure AI Content Safety). The severity score, rather than a flat pass/fail, is what makes confidence-based routing (below) practical to implement directly against the classifier's own output.

Diagram of Azure AI Content Safety's four harm categories — Hate and Fairness, Sexual, Violence, and Self-Harm — each scored on a 0 to 7 severity scale, with content able to receive multiple category flags at once

Domain-specific policy checks

General moderation APIs are deliberately broad and will not catch violations specific to your product — a legal-advice chatbot giving definitive legal conclusions, a healthcare assistant making diagnostic claims, or a customer service agent inventing refund policies that don't exist. These require purpose-built checks: keyword or pattern rules, a secondary "policy-checking" model call, or retrieval-grounding verification (confirming the response's claims match your actual knowledge base) — the same grounding pattern used in AI safety guardrail design generally.

How a Moderation Pipeline Fits Together

A typical production pipeline runs moderation at two or three points:

  1. Pre-inference input check — reject or flag the prompt before it reaches the model.
  2. Post-inference output check — classify the model's response before it reaches the user.
  3. Domain policy check — verify the response against product-specific rules (may run in parallel with step 2 to control latency).
Stage Catches Typical implementation
Input moderation Abusive prompts, jailbreak/injection attempts, disallowed requests Fast classifier call + pattern matching, run before the model call
Output moderation Hate, violence, self-harm, sexual content, illicit content in generated text/images General-purpose moderation classifier (e.g., a moderation API)
Domain policy check Product-specific rule violations, ungrounded claims, out-of-scope advice Custom rules, secondary model call, or grounding/retrieval verification
Content labeling Disclosure obligations for synthetic/AI-generated content Machine-readable watermarking/metadata + visible UI labeling

What to do with a flagged item

Not every flag should result in an automatic block. A practical routing model:

Diagram of a three-tier confidence-based moderation routing model: high-confidence violations are automatically blocked, moderate-confidence cases escalate to human review, and low-confidence cases are allowed but logged for review
  • High-confidence violation (e.g., clear sexual content involving minors, clear violent threats) → automatic block, no human in the loop, with the incident logged for audit.
  • Moderate confidence → escalate to human review before the content reaches the user, or hold the response and return a generic "unable to help with that request" fallback.
  • Low confidence / ambiguous → allow, but log for periodic review and model/classifier tuning.
A moderation system without logging is not auditable

If you can't answer "how many requests did we block last month, and why," you don't actually have a moderation system — you have a single point of failure you can't inspect or improve.

Regulatory Context: What the EU AI Act Requires

For organisations operating in or serving the EU, content moderation now intersects directly with a legal disclosure requirement, separate from harm-category filtering. Article 50 of the EU AI Act requires that providers mark generative AI outputs — synthetic audio, image, video, and text — with "effective, reliable, robust and interoperable machine-readable marks," and that deployers clearly label deepfakes and AI-generated or manipulated text covering public-interest matters (politics, health, justice, and similar topics) unless the text underwent human review and editorial control (European Commission — Digital Strategy, Article 50 FAQ). These obligations apply from 2 August 2026, with a limited grace period to 2 December 2026 for marking obligations on systems already on the market before that date. Non-compliance can result in penalties of up to €15 million or 3% of global annual turnover.

Timeline showing EU AI Act Article 50 transparency obligations taking effect on 2 August 2026, with a grace period for marking obligations on existing systems ending 2 December 2026
This is a legal disclosure requirement, not a content-safety filter

Labeling content as AI-generated does not make it "safe" — it's a separate transparency obligation that sits alongside, not instead of, harm-category moderation. Whether a specific product or output is in scope of Article 50, and how to implement compliant labeling, are legal and product questions that should be confirmed with qualified counsel; this section describes the directive's published requirements, not legal advice.

The broader NIST AI Risk Management Framework's Generative AI Profile (NIST AI 600-1) identifies related content risks worth designing against even outside the EU, including the potential for generative systems to lower the barrier to producing non-consensual intimate imagery and CSAM via deepfake techniques, large-scale mis/disinformation, and "confabulation" — model-generated false information a user may believe and act on (Davis Wright Tremaine's summary of the NIST profile). NIST's recommended mitigations for these risks include enhanced human oversight and management review of outputs, content provenance techniques such as watermarking, pre-deployment red-teaming and field testing, and structured incident reporting when harms do occur.

Trade-offs and Decision Guidance

Approach When it makes sense Trade-off
General-purpose moderation API only Early-stage products, low-risk domains, tight timelines Fast to implement, but misses domain-specific policy violations entirely
General API + custom domain rules Regulated or higher-risk domains (health, legal, finance, children's products) More engineering effort and ongoing tuning, but catches product-specific risks
Human-in-the-loop for all flags Low-volume, high-stakes applications Highest safety confidence, but does not scale with volume and adds latency
Automated routing by confidence tier Higher-volume production systems Scales well, but requires ongoing calibration to avoid over- or under-blocking

Common Mistakes

Moderating only the output, not the input

This wastes inference cost generating a response to a request that should have been rejected outright, and misses prompt-injection style attacks aimed at the moderation layer itself.

Treating a general moderation API as a complete solution

It covers broad harm categories well; it has no knowledge of your product's specific policies, so relying on it alone leaves domain-specific risks (false medical/legal/financial claims, brand policy violations) uncovered.

No confidence-based routing

Binary allow/block decisions either over-block legitimate use (frustrating users) or under-block genuinely harmful content (a safety failure) — most systems need a middle tier that escalates to a human or a fallback response.

Skipping content labeling because it "feels like a UX detail"

In the EU, this is now a binding legal transparency obligation under AI Act Article 50 for a wide range of generative outputs, with substantial penalties for non-compliance.

No feedback loop from moderation logs back into the system

Without regularly reviewing what got flagged, blocked, or missed, moderation quality drifts as usage patterns change and adversarial users adapt.

Cost, Complexity, and Timeline

A basic input/output moderation layer using an existing moderation API is low-to-moderate implementation effort — mostly integration work, since the classification itself is handled by the provider. Adding domain-specific policy checks is moderate-to-significant effort, since it typically requires either a secondary model call (added latency and inference cost) or hand-built rules that need ongoing maintenance as your product's policies evolve. Multimodal (image/video) moderation is generally higher latency and cost than text-only moderation and should be scoped and budgeted separately rather than assumed to be a drop-in extension. Building confidence-based routing and a human review queue is a moderate, ongoing operational investment — someone has to actually staff and act on the review queue, not just build it.

Security and Governance Considerations

Log every moderation decision with enough context (input, output, category scores, action taken) to support an audit — both for your own quality improvement and, in the EU, to demonstrate compliance with transparency obligations if asked. Treat moderation configuration (thresholds, blocked categories, escalation rules) as a governed change, reviewed the same way you'd review an access-control policy change, since loosening a threshold is effectively a safety decision. Be explicit about who owns the human review queue operationally — an escalation path that nobody is actually staffed to act on is not a functioning guardrail, it's a queue that silently grows.

How Halden Solutions Approaches This

We treat content moderation as one layer of a broader AI safety guardrail design, not a bolt-on filter added at the end. In practice that means scoping input and output moderation together from the start — including a dedicated prompt-injection detection layer, not just harm-category classification — identifying which domain-specific policies actually need custom checks rather than assuming a general moderation API covers them, and building the confidence-based routing and logging needed to make the system auditable. Where clients have EU exposure, we treat AI Act labeling obligations as a compliance requirement to confirm with legal counsel early, rather than a UI afterthought bolted on right before launch.

Frequently Asked Questions

Is a moderation API alone sufficient for a production generative AI product?

For broad harm categories like hate speech, violence, and sexual content, a general-purpose moderation API is a reasonable and often necessary baseline. It is not sufficient on its own for domain-specific risks — false claims in regulated domains, brand policy violations, or product-specific misuse — which require custom checks.

Do we need to moderate both the prompt and the response?

Yes. Input moderation prevents abusive or manipulative prompts from reaching the model and wasting inference cost on requests that should be rejected outright; output moderation catches harmful content the model generates even from seemingly benign prompts.

Is prompt injection the same thing as harmful content generation?

No — they're distinct threats. Harmful content generation is about the model producing disallowed output; prompt injection is about an attacker manipulating the model's instructions or behavior, sometimes via content hidden in a document the model processes rather than the user's own prompt. Purpose-built tools like Azure AI Content Safety's Prompt Shields address injection specifically, separate from harm-category classification.

Is labeling AI-generated content legally required?

In the EU, yes for a broad set of cases — Article 50 of the AI Act requires machine-readable marking of synthetic audio/image/video/text and visible labeling of deepfakes and certain AI-generated text, effective from 2 August 2026. Requirements outside the EU vary by jurisdiction; confirm applicability with legal counsel.

How much latency does moderation add?

It depends on architecture — a fast text classifier adds comparatively little latency, while multimodal (image/video) checks and secondary domain-policy model calls add more. This should be measured for your specific stack rather than assumed, and budgeted into your response-time targets from the start.

Conclusion

Effective generative AI content moderation is not a single API call — it's a pipeline that checks input and output separately (with prompt injection treated as its own distinct threat), layers domain-specific policy checks on top of general harm-category classifiers, routes ambiguous cases to humans rather than forcing a binary decision, and treats content labeling as a compliance requirement rather than a nice-to-have. Building this well from the start is considerably cheaper than retrofitting it after an incident forces the issue.

Working through content moderation and broader AI safety design for a generative AI product? Halden Solutions' Data & AI team can help you scope a pipeline that matches your actual risk profile. See also our guide to AI safety guardrails.


Sources

  1. OpenAI — "Upgrading the Moderation API with our new multimodal moderation model"
  2. Davis Wright Tremaine — "Latest NIST Guidance Identifies Generative AI Risks and Corresponding Mitigation Strategies" (summarizing NIST AI 600-1, the Generative AI Profile)
  3. European Commission, Digital Strategy — "Transparency obligations under Article 50 of the AI Act"
  4. NIST — "AI Risk Management Framework"
  5. Microsoft Learn — Prompt Shields in Azure AI Content Safety
  6. Microsoft Learn — Harm categories in Azure AI Content Safety