[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Evals & Moderation

💰 Production & Cost Optimization 12 min 250 BASE XP

Evaluating AI Quality

Evals are automated tests that measure your AI system's quality. OpenAI provides an evaluation framework for testing model outputs against expected results.

Types of Evals

Eval TypeMethodBest For
Exact MatchOutput must match expected value exactlyClassification, structured data
LLM-as-JudgeA separate model scores the output qualityCreative writing, summaries
Semantic SimilarityEmbedding distance between output and expectedOpen-ended questions
Human ReviewManual scoring by domain expertsComplex, subjective tasks

The Moderation API

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.";
}
🔒 Production Rule: Always run user inputs through the Moderation API before passing them to your main model. It's free and prevents harmful content from entering your pipeline.
SYNAPSE VERIFICATION
QUERY 1 // 3
What is an 'LLM-as-Judge' eval?
A legal AI tool
Using a separate model to score the quality of another model's output
A benchmarking competition
A moderation filter
Watch: 139x Rust Speedup
Evals & Moderation | Production & Cost Optimization — OpenAI Academy