Getting started
LLMock is a local server that answers like an LLM API: OpenAI chat completions and Responses, Gemini, or the Anthropic Messages API. Point your app's SDK at it and you get realistic replies with no API key, no cost and no network.
This page takes about five minutes: create a project, start the server, send it a request.
Prerequisites
- Node.js 24 or later (26 LTS recommended; it is the version LLMock is tested on)
- A terminal, and
curlor an LLM SDK to send requests with
Create a project
The scaffolding tool creates a project with a config file, editable templates and a Docker setup:
npm create llmock@latest my-project
cd my-project
npm installAlready have a project?
Add LLMock to it with npm install llmock and use npx llmock start in place of the npm run scripts on this page. See Installation for that, and for Docker.
File structure
my-project/
├── .llmockrc.json # presets: which API to mimic, delays, chaos, rules
├── request-templates/ # what a valid request looks like, per provider
├── response-templates/ # the shape of each provider's reply
├── Dockerfile
├── docker-compose.yml
├── package.json
└── README.md.llmockrc.json is the file you will edit most. It is described in Configuration.
Up and running
Start the server with the preset for the API your app calls:
npm run llmock:chatgptnpm run llmock:claudenpm run llmock:gemininpm run llmock:streaming # OpenAI-style, streams by defaultnpm run llmock:embeddingsThe server runs in the background on port 8001. Open http://localhost:8001 in your browser to see the live dashboard: the preset in use, its settings, and every request as it arrives.
Send a request
Point your SDK at LLMock in place of the real API. Any API key will do.
curl http://localhost:8001/chatgpt/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'import OpenAI from 'openai';
const client = new OpenAI({ apiKey: 'mock', baseURL: 'http://localhost:8001/chatgpt' });
const reply = await client.chat.completions.create({
model: 'gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(reply.choices[0].message.content);// Start the server with: npm run llmock:claude
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ apiKey: 'mock', baseURL: 'http://localhost:8001' });
const reply = await client.messages.create({
model: 'claude-opus-5-5',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(reply.content);The reply has the real API's shape, with generated text in it. The request shows up on the dashboard.
Want a specific reply?
Generated text is the default. To answer a chosen prompt with your own text, JSON or a tool call, add a response rule.
Stop the server
npm run llmock:stopWhat's next?
Pick what you want to do:
- Return a fixed reply for a given prompt: Response rules
- Test an agent's tool loop (Claude): Tool calls
- Use real replies, offline: Recording real replies
- Test retries and error handling: Chaos mode, or fail one prompt
- Test loading states and timeouts: Response delays
- Start a server from your tests and check what your code sent: Using LLMock in tests
- Change replies while it runs: Admin API
- Connect LangChain, embeddings or the Responses API: Integration
- Run it in Docker or CI: Docker
When you want the details, every CLI option is in the CLI reference and every config key in Configuration. If something isn't working, see Troubleshooting.