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

Evals & Moderation

💰 Production & Cost Optimization 12 min 250 BASE XP⌨ HANDS-ON LAB

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.
⌨ HANDS-ON LABScreen Content with the Moderation API
⭐ +150 XP

Before user text reaches your agent, it must pass through a safety gate. Wire up the free Moderation endpoint and inspect its category scores.

1POST user text to /v1/moderations using the omni-moderation-latest model.
2Pipe the response through jq to inspect the numeric category_scores - your thresholds live here.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
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