Skip to content

Introduction

A mock server that mimics the OpenAI API for predictable testing
config.yaml
apiKey: 'test-key'
port: 3000
responses:
- id: 'greeting'
messages:
- role: 'user'
content: 'hello'
matcher: 'contains'
- role: 'assistant'
content: 'Hello! How can I help you today?'
// Your test code
const openai = new OpenAI({
baseURL: 'http://localhost:3000/v1',
apiKey: 'test-key',
});
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Say hello!' }],
});
// Returns: "Hello! How can I help you today!"

Testing LLM applications is hard because:

  • Real API responses vary each time
  • API calls cost money and have rate limits
  • Network issues can break tests
  • You can’t test specific edge cases reliably

This mock server solves these issues by giving you complete control over responses during testing.