Evals are automated tests that measure your AI system's quality. OpenAI provides an evaluation framework for testing model outputs against expected results.
| Eval Type | Method | Best For |
|---|---|---|
| Exact Match | Output must match expected value exactly | Classification, structured data |
| LLM-as-Judge | A separate model scores the output quality | Creative writing, summaries |
| Semantic Similarity | Embedding distance between output and expected | Open-ended questions |
| Human Review | Manual scoring by domain experts | Complex, subjective tasks |
The Moderation API is a free endpoint that classifies text into safety categories (hate, violence, self-harm, sexual content). Use it as a pre-filter before processing user input.
const moderation = await openai.moderations.create({
input: userMessage
});
if (moderation.results[0].flagged) {
return "This content violates our usage policy.";
}