Skip to main content
This guide will walk you through running your first safety evaluations using the Circuit Breaker Labs CLI. You’ll learn how to run both single-turn and multi-turn evaluations against OpenAI models.

Prerequisites

Before you begin, make sure you have:
1

Installed the CLI

Follow the Installation Guide to install cbl on your system.
2

Set Up API Keys

Export your required API keys:
Don’t have a Circuit Breaker Labs API key? Contact team@circuitbreakerlabs.ai to get access.
3

Verify Installation

Confirm cbl is working:

Your First Single-Turn Evaluation

Single-turn evaluations test how your model responds to individual unsafe prompts. Let’s run a basic evaluation against GPT-4:

Basic Single-Turn Command

This evaluation will:
  • Test the gpt-4o-mini model against the default suicidal_ideation test case group
  • Generate 2 variations of each unsafe prompt
  • Use up to 2 iteration layers for adversarial refinement
  • Fail any responses with a safety score below 0.5

Understanding the Command

Let’s break down each part:

Watch the Progress

When you run the command, you’ll see an interactive TUI (terminal user interface) showing:
  • Current test case being evaluated
  • Number of prompts sent and responses received
  • Safety scores in real-time
  • Progress through iteration layers

View the Results

After the evaluation completes, cbl saves a detailed JSON report:
To specify a custom output file:

Your First Multi-Turn Evaluation

Multi-turn evaluations test conversational safety across multiple dialogue turns. This is crucial for chatbots and conversational AI systems.

Basic Multi-Turn Command

This evaluation will:
  • Test gpt-4o-mini in conversational scenarios
  • Run conversations up to 8 turns (4 user messages, 4 assistant responses)
  • Use both user_persona and semantic_chunks test types
  • Apply the default suicidal_ideation test case group
  • Fail responses with safety scores below 0.5

Understanding Multi-Turn Parameters

Multi-Turn Test Types

  • user_persona: Tests with simulated user personas attempting to elicit unsafe responses
  • semantic_chunks: Tests by breaking unsafe content into semantic segments across turns
You can specify both test types or just one. Using both provides more comprehensive coverage.

Results

Multi-turn evaluations also generate timestamped JSON reports:

Advanced Examples

Testing a Custom Fine-Tune

Using Ollama for Local Models

Testing Multiple Test Case Groups

Log Mode (No TUI)

If you’re running in CI/CD or prefer log output:

Custom Provider Example

Custom providers require a Rhai script to translate between Circuit Breaker Labs protocol and your API’s format. See the examples/providers/ directory for script templates.

Understanding the Output

JSON Report Structure

The evaluation report contains:
  • Summary: Overall pass/fail status, total tests, safety scores
  • Test Cases: Detailed results for each test case
  • Prompts and Responses: Full conversation history with safety scores
  • Metadata: Model info, parameters, timestamps
Example structure:

Interpreting Safety Scores

  • 1.0: Completely safe response
  • 0.7-0.9: Mostly safe, minor concerns
  • 0.4-0.6: Moderate safety issues
  • 0.0-0.3: Significant safety concerns
Set your --threshold based on your risk tolerance. Common values:
  • 0.5: Balanced (default for testing)
  • 0.7: More strict (production chatbots)
  • 0.3: More lenient (research/development)

Provider-Specific Options

OpenAI Provider

Ollama Provider

Custom Provider

Common Parameter Reference

Global Options

Single-Turn Options

Multi-Turn Options

Troubleshooting

Check that:
  1. Your CBL_API_KEY is set correctly
  2. You have an active internet connection
  3. Your firewall allows WebSocket connections
Try running with --log-mode --log-level debug for more details.
Verify your OpenAI API key:
Make sure it starts with sk- and is valid. You can test it:
Ensure Ollama is running:
If using a custom host:
For OpenAI: Verify the model name or fine-tune ID is correct.For Ollama: Make sure the model is pulled:
Reduce the test scope:
  • Lower --variations (try 1 or 2)
  • Reduce --maximum-iteration-layers (try 1)
  • Decrease --max-turns for multi-turn tests
  • Test fewer --test-case-groups

Best Practices

1

Start Small

Begin with minimal parameters to understand evaluation duration:
2

Iterate on Thresholds

Adjust --threshold based on your risk profile:
  • Start at 0.5 for baseline
  • Increase to 0.7-0.8 for production systems
  • Lower to 0.3-0.4 for research/development
3

Use Log Mode for CI/CD

In automated pipelines, use --log-mode for structured output:
4

Version Control Your Scripts

Save your evaluation commands in scripts:

Next Steps

GitHub Repository

Explore example scripts and advanced configurations

Custom Providers

Learn how to integrate custom model endpoints

API Documentation

Deep dive into the Circuit Breaker Labs API

Get Support

Contact the team for help or questions

Example Workflow

Here’s a complete workflow from installation to analysis:

Questions? Reach out to team@circuitbreakerlabs.ai