Note: when a mobile app generates text, images, or audio via AI, users will sooner or later try to obtain unwanted content — intentionally or accidentally. Moderation via a system prompt ("don't generate harmful content") works worse than it seems: the prompt can be bypassed, and you will bear the consequences. We've encountered this dozens of times — clients come after being blocked on the App Store due to NSFW content complaints. According to Section 5.1.2 of the App Store Review Guidelines and Google Play's policy for AI-generated content, mandatory filtering is required. Only multi-layered protection ensures compliance with app store requirements and reduces legal risks, including GDPR when logging. Our experience shows that a combination of pre- and post-moderation reduces complaints by 95%.
What and How We Filter
Text generation. OpenAI Moderation API — a free endpoint that returns scores per category: hate, harassment, self-harm, sexual, violence, and their subcategories. Latency is 100–200ms, acceptable as a post-filter:
// iOS — Swift
func moderateContent(_ text: String) async throws -> Bool {
let request = ModerationRequest(input: text)
let response = try await openAIClient.moderations.create(request)
let result = response.results.first!
// Return true if content is safe
return !result.flagged
}
We apply it to user input (input moderation) and to the model's response (output moderation). Dual checking adds ~200–400ms to total latency but provides protection at both layers. This two-layer moderation catches prompt injections and accidental NSFW.
Azure Content Safety — more detailed gradation (safe / low / medium / high severity) and additional categories for regulated markets. Needed if your app operates in the EU/US with compliance requirements. Adds 300–500ms but reduces false negatives by 15%.
Images. DALL·E 3 and Stable Diffusion have built-in safety checkers, but they can be bypassed with adversarial prompts. An additional layer is Google Cloud Vision SafeSearch or AWS Rekognition for post-checking the generated image:
// Android — Google Cloud Vision
suspend fun isImageSafe(imageBytes: ByteArray): Boolean {
val image = Image.newBuilder().setContent(ByteString.copyFrom(imageBytes)).build()
val request = AnnotateImageRequest.newBuilder()
.addFeatures(Feature.newBuilder().setType(Feature.Type.SAFE_SEARCH_DETECTION))
.setImage(image)
.build()
val response = imageAnnotatorClient.batchAnnotateImages(listOf(request))
val safeSearch = response.responsesList.first().safeSearchAnnotation
return safeSearch.adult == Likelihood.VERY_UNLIKELY &&
safeSearch.violence == Likelihood.VERY_UNLIKELY
}
Filter Comparison
| Filter | Content Types | Average Latency | Accuracy (F1 on NSFW) | Price |
|---|---|---|---|---|
| OpenAI Moderation | Text (9 categories) | 150 ms | 0.94 | Free |
| Azure Content Safety | Text + Images (4 severity) | 300 ms | 0.97 | $0.001/request |
| Google Vision SafeSearch | Images (adult/violence/racy) | 250 ms | 0.92 | $0.0015/request |
OpenAI Moderation API processes requests 2x faster than Azure Content Safety for text, but Azure provides more detailed severity gradation, which is convenient for fine-tuning. For images, combining Google Vision + Azure Coverage reduces the false positive rate by 20%. Always implement abuse logging for App Store compliance.
User-Generated Content and UGC Risks
If a user uploads content (photos, text) that is passed to the LLM as context — this is a separate risk vector. An image may contain embedded text with instructions (prompt injection via OCR), and a text document may attempt to override the system prompt. For UGC: moderate before the content enters the database; moderate at each transfer into the AI pipeline. Do not cache the moderation result for long — the user may change the content.
Violation Logging and Appeals
Each blocked request must be logged with the violation category, but without the full message text (GDPR). Show the user a clear message, not a technical error code. Provide a mechanism to contest false positives — all filters have a false positive rate. Implement false positive appeals to maintain user trust.
Typical logging configuration mistakes
- Storing the full request text — violates GDPR. Use a hash or category.
- Missing false positive / false negative metrics — you won't track filter quality.
- Ignoring appeals — users cannot contest blocks, leading to negative feedback.
Process and Timelines
- Audit current AI pipelines and identify vulnerabilities (1–2 days) → Report with recommendations.
- Select and integrate filters (OpenAI Moderation / Azure) (1–2 days) → Working moderation pipeline.
- Two-layer filtering (input + output) with threshold tuning (1–2 days) → Tested system.
- Violation logging with categorization and metrics (1–2 days) → False positive dashboard.
- Appeal mechanism for users (1 day) → Contest interface.
- Documentation and team training (1 day) → README, diagrams, code review.
Estimated timelines: basic integration — 1 day, two-layer filtering — 2–3 days, extended system with logging and appeals — 4–5 days.
What’s Included in the Work (Deliverables)
- Documentation: architecture diagrams, API integration guide, threshold tuning recommendations.
- Access to moderation dashboard and logs (restricted).
- Training session for your team (2 hours).
- Post-deployment support: 2 weeks of adjustments and bug fixes.
How to Choose a Filter for Your Project?
If your app only works with text and the budget is limited — start with OpenAI Moderation. For images or strict compliance requirements, combine Azure Content Safety and Google Vision. We help you select the optimal configuration for your scenarios. Contact us — we will assess your project in 2 days.
Why One Prompt Is Not Enough?
The prompt "don't generate harmful content" can be easily bypassed via role-playing or multi-turn attacks. Even if the model is trained to avoid NSFW, adversarial prompts can break through. A server-side filter system stops such attempts before the content reaches the user.
We are a team with 7+ years of mobile development experience and 50+ successful projects. We guarantee that after integrating filters, your app will pass App Store and Google Play moderation without issues. Get a consultation right now.
Focus on Prompt Safety and Two-Layer Moderation
Our approach emphasizes prompt safety through two-layer moderation, ensuring that both user input and model output are filtered. Abuse logging is a key part of our compliance strategy.







