AI / Core OpenAI Codex Application Fundamentals Interview Questions
What is the OpenAI moderation API and why is it important for application safety?
The Moderation API classifies text (and now images) against OpenAI's usage policies, detecting harmful content across multiple categories. It is free to use and essential for any application that accepts user-generated content.
from openai import OpenAI client = OpenAI() # Standalone moderation check response = client.moderations.create( model="omni-moderation-latest", input="I want to hurt someone.", ) result = response.results[0] if result.flagged: print("Content flagged!") for category, flagged in result.categories.__dict__.items(): if flagged: print(f" - {category}: score {getattr(result.category_scores, category):.3f}") # Image moderation (omni-moderation-latest supports images): response = client.moderations.create( model="omni-moderation-latest", input=[ {"type": "text", "text": "Check this text"}, {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}} ] ) # Inline moderation with Responses API (2026 feature): response = client.responses.create( model="gpt-5.5", input="User message here", moderation={}, # get moderation scores inline with the response )
| Category | What it detects |
|---|---|
| hate | Content promoting hatred based on protected characteristics |
| harassment | Content targeting individuals with threats or abuse |
| self-harm | Content promoting self-injury or suicide |
| sexual | Explicit or suggestive sexual content |
| violence | Graphic violence or glorification of harm |
| illicit | Instructions for illegal activities |
Best practice: run moderation on user inputs before sending to the model to prevent policy violations. The Moderation API is free - there is no reason not to use it in consumer-facing applications. In 2026, OpenAI added inline moderation scores directly to the Responses API, enabling a single request to get both the model's response and moderation results.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
