Prerequisites
Before you begin, make sure you have:Installed the CLI
Follow the Installation Guide to install
cbl on your system.Set Up API Keys
Export your required API keys:
Don’t have a Circuit Breaker Labs API key? Contact [email protected] to get access.
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-minimodel against the defaultsuicidal_ideationtest 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:
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-miniin conversational scenarios - Run conversations up to 8 turns (4 user messages, 4 assistant responses)
- Use both
user_personaandsemantic_chunkstest types - Apply the default
suicidal_ideationtest 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 responsessemantic_chunks: Tests by breaking unsafe content into semantic segments across turns
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
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
Provider-Specific Options
OpenAI Provider
Ollama Provider
Custom Provider
Common Parameter Reference
Global Options
| Flag | Description | Default |
|---|---|---|
--cbl-api-key | Circuit Breaker Labs API key | $CBL_API_KEY |
--cbl-api-base-url | CBL API endpoint | https://api.circuitbreakerlabs.ai/v1 |
--output-file | Custom output filename | Auto-generated timestamp |
--log-mode | Disable TUI, show logs | false |
--log-level | Log verbosity | info |
--add-header | Add custom HTTP headers | None |
Single-Turn Options
| Flag | Description | Required |
|---|---|---|
--threshold | Safety score threshold (0.0-1.0) | Yes |
--variations | Prompt variations per test | Yes |
--maximum-iteration-layers | Adversarial refinement depth | Yes |
--test-case-groups | Test categories (comma-separated) | Default: suicidal_ideation |
Multi-Turn Options
| Flag | Description | Required |
|---|---|---|
--threshold | Safety score threshold (0.0-1.0) | Yes |
--max-turns | Maximum conversation turns (even number) | Yes |
--test-types | Test strategies (comma-separated) | Yes |
--test-case-groups | Test categories (comma-separated) | Default: suicidal_ideation |
Troubleshooting
Connection failed to Circuit Breaker Labs API
Connection failed to Circuit Breaker Labs API
Check that:
- Your
CBL_API_KEYis set correctly - You have an active internet connection
- Your firewall allows WebSocket connections
--log-mode --log-level debug for more details.OpenAI API authentication error
OpenAI API authentication error
Verify your OpenAI API key:Make sure it starts with
sk- and is valid. You can test it:Ollama connection refused
Ollama connection refused
Ensure Ollama is running:If using a custom host:
Model not found error
Model not found error
For OpenAI: Verify the model name or fine-tune ID is correct.For Ollama: Make sure the model is pulled:
Evaluation is taking too long
Evaluation is taking too long
Reduce the test scope:
- Lower
--variations(try 1 or 2) - Reduce
--maximum-iteration-layers(try 1) - Decrease
--max-turnsfor multi-turn tests - Test fewer
--test-case-groups
Best Practices
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
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 [email protected]