Moderation Gate Before Generation
A 3-step recipe with ChatGPT. We can help you get access.
Recipe · 3 steps
Moderation Gate Before Generation
with ChatGPT · Artificial Intelligence Management
Use a chat-completion safety classification to gate a Responses API generation.
- Ask a chat completion to classify the input as SAFE or UNSAFE, returning a JSON object so the verdict can be branched on deterministically.
- Generate the answer with the Responses API now that the input has passed the safety gate.
- The classifier flagged the input as unsafe, so no generation is performed. This terminal step records the rejection.
What you'll need to have ready
- apiKey: OpenAI API key used as the Bearer credential.
- classifierModel: Model ID used for the safety classification (e.g. gpt-4o-mini).
- generationModel: Model ID used for the downstream generation (e.g. gpt-4o).
- userInput: The user input to screen and then answer.
For your developer
Arazzo workflow chatgpt:moderation-gate-generate, 3 operations: createChatCompletion → createResponse → createChatCompletion. Specs on APIs.io.