Skip to content

Quick Reference

Fast lookup for common tasks, commands, and configurations.

Quick Reference Guides

GuideDescription
CommandsAPI calls and function signatures
GradersGrader types and configurations
ConfigurationSettings and thresholds
TroubleshootingCommon issues and solutions

Quick Start Snippets

Initialize OpenAI Client

python
from openai import OpenAI
client = OpenAI()  # Uses OPENAI_API_KEY env var

Create Basic Eval

python
eval_config = client.evals.create(
    name="my-eval",
    data_source_config={"type": "custom", "item_schema": {...}},
    testing_criteria=[grader1, grader2]
)
EVAL_ID = eval_config.id

Run Eval

python
run = client.evals.runs.create(
    eval_id=EVAL_ID,
    data_source={"type": "jsonl", "source": {...}}
)

Create Agent

python
from agents import Agent, Runner

agent = Agent(
    name="SummarizationAgent",
    instructions="Your prompt here",
    model="gpt-5"
)

result = await Runner.run(agent, "Input text")
summary = result.final_output

Key Thresholds

ThresholdValueDescription
LENIENT_PASS_RATIO0.75Min % of graders that must pass
LENIENT_AVERAGE_THRESHOLD0.85Min average score to pass
MAX_OPTIMIZATION_RETRIES3Max prompt optimization attempts
WORD_LENGTH_TARGET80Target summary word count
WORD_LENGTH_DEVIATION0.35Allowed deviation from target
COSINE_THRESHOLD0.5Min cosine similarity

Model Selection

ModelBest ForCost
gpt-5Highest quality, critical tasks$$$
gpt-4.1General use, good balance$$
gpt-5-miniHigh volume, budget$

Optimization Methods

MethodUse When
Platform UIRapid iteration, exploration
Static MetapromptAutomation, production
GEPARobust generalization, multi-objective

Common Patterns

Check Lenient Pass

python
def is_lenient_pass(grader_scores, average_score):
    passed_count = sum(1 for e in grader_scores if e.get("passed"))
    if (passed_count / len(grader_scores)) >= 0.75:
        return True
    return average_score >= 0.85

Calculate Average Score

python
def calculate_grader_score(grader_scores):
    return sum(e.get("score", 0) for e in grader_scores) / len(grader_scores)

Version Prompt

python
from datetime import datetime

class VersionedPrompt:
    def __init__(self, initial_prompt, model="gpt-5"):
        self._versions = [{"version": 0, "prompt": initial_prompt, "model": model}]

    def update(self, new_prompt, model="gpt-5"):
        self._versions.append({
            "version": len(self._versions),
            "prompt": new_prompt,
            "model": model
        })

    def current(self):
        return self._versions[-1]

Based on OpenAI Cookbook - Bain & OpenAI Collaboration