Quick Start
Minimal Configuration
The simplest way to use the Mocker plugin is with no configuration - it will create a default catch-all rule:Custom Response
Responses Request Example
The mocker plugin automatically handles both chat completion and responses requests with the same configuration:Installation
Add the plugin to your project:Basic Usage
Creating the Plugin
Adding to Bifrost
Disabling the Plugin
Supported Request Types
The Mocker plugin supports the following Bifrost request types:- Chat Completion Requests (
ChatCompletionRequest) - Standard chat-based interactions - Responses Requests (
ResponsesRequest) - OpenAI-compatible responses API format - Skip Context Key - Use
"skip-mocker"context key to bypass mocking per request
Skip Mocker for Specific Requests
You can skip the mocker plugin for specific requests by adding a context key:Key Features
Template Variables
Create dynamic responses using templates:{{provider}}- Provider name (e.g., “openai”, “anthropic”){{model}}- Model name (e.g., “gpt-4”, “claude-3”){{faker.*}}- Fake data generation (see Configuration Reference)
Weighted Response Selection
Configure multiple responses with different probabilities:Latency Simulation
Add realistic delays to responses:Advanced Matching
Regex Message Matching
Request Size Filtering
Faker Data Generation
Create realistic test data using faker variables:Statistics and Monitoring
Get runtime statistics for monitoring:Configuration Reference
MockerConfig
MockRule
Conditions
Response
SuccessResponse
ErrorResponse
Latency
Important: Use Go’s
time.Duration constants:
- ✅ Correct:
100 * time.Millisecond - ❌ Wrong:
100(nanoseconds, barely noticeable)
Faker Variables
Personal Information
{{faker.name}}- Full name{{faker.first_name}}- First name only{{faker.last_name}}- Last name only{{faker.email}}- Email address{{faker.phone}}- Phone number
Location
{{faker.address}}- Street address{{faker.city}}- City name{{faker.state}}- State/province{{faker.zip_code}}- Postal code
Business
{{faker.company}}- Company name{{faker.job_title}}- Job title
Text and Data
{{faker.lorem_ipsum}}- Lorem ipsum text{{faker.lorem_ipsum:10}}- Lorem ipsum with 10 words{{faker.uuid}}- UUID v4{{faker.hex_color}}- Hex color code
Numbers and Dates
{{faker.integer}}- Random integer (1-100){{faker.integer:10,50}}- Random integer between 10-50{{faker.float}}- Random float (0-100, 2 decimals){{faker.float:1,10}}- Random float between 1-10{{faker.boolean}}- Random boolean{{faker.date}}- Date (YYYY-MM-DD format){{faker.datetime}}- Datetime (YYYY-MM-DD HH:MM:SS format)
Best Practices
Rule Organization
Development vs Production
Performance Considerations
- Place specific conditions before general ones (higher priority)
- Use simple string matching over complex regex when possible
- Keep response templates reasonably sized
- Consider disabling debug logging in production
Testing Your Configuration
Common Issues
Plugin Not Triggering
- Check if plugin is enabled:
Enabled: true - Verify rule is enabled:
rule.Enabled: true - Check probability:
Probability: 1.0for testing - Verify conditions match your request
Latency Not Working
Usetime.Duration constants, not raw integers:
Regex Not Matching
Test your regex pattern and ensure proper escaping:Controlling Fallbacks
Skip Mocker Not Working
Ensure you’re using the correct context key format:Responses Request Issues
If responses requests aren’t being mocked:- Verify the plugin supports
ResponsesRequest(version 1.2.13+) - Check that your regex patterns match the message content
- Ensure the request type is
schemas.ResponsesRequest

