# llmao > llmao is a fake LLM powered by regex. It is a drop-in replacement for the OpenAI (`openai`) and Anthropic (`@anthropic-ai/sdk`) Node.js SDKs and a Vercel AI SDK provider, used to test code that calls LLMs in Jest, Vitest, node:test or any runner, without API keys. It is also a joke. - Install: `npm install --save-dev llmao` (Node 18+, zero runtime dependencies, MIT) - Jest: `jest.mock('openai', () => require('llmao/openai'))`. Vitest: `vi.mock('openai', () => import('llmao/openai'))`. Same for `@anthropic-ai/sdk` → `llmao/anthropic`, and `@ai-sdk/openai` / `@ai-sdk/anthropic` → `llmao/ai-sdk` (the AI SDK is ESM-only: in Jest use ESM mode and `jest.unstable_mockModule`) - `import * as llmao from 'llmao/testing'` turns on test mode (instant, deterministic, no timers) and gives `configure()`, `reset()`, `calls` and `lastCall()` - Scripted answers: `configure({ script: [{ when: /regex/ | 'substring' | fn, text, toolCalls, object, error, once, afterToolResults }], unscripted: 'error' })` - Simulated failures: `configure({ failures: { rateLimit, serverError, timeout, retryAfter } })` throw the SDKs' real error classes (`OpenAI.RateLimitError` with status 429 and a retry-after header, `Anthropic.InternalServerError`, the AI SDK's `APICallError`) - Any language or runner: `npx llmao serve` (or `serve()` from `llmao/server`) is an OpenAI and Anthropic compatible HTTP server; point SDKs at it with `OPENAI_BASE_URL` / `ANTHROPIC_BASE_URL` - Structured output (`generateObject`, `response_format`, `output_config`) returns objects that validate against the schema ## Docs - [How to mock the OpenAI SDK in Jest](https://icernigoj.github.io/llmao/mock-openai-jest.md): Test code that calls OpenAI in Jest without an API key. Script the answers, simulate rate limits and assert on the prompts your app sent, with one jest.mock line. - [How to mock the OpenAI SDK in Vitest](https://icernigoj.github.io/llmao/mock-openai-vitest.md): Mock the openai package in Vitest with vi.mock and llmao. Scripted answers, recorded calls, streaming, tool calls and real SDK errors, without an API key. - [How to mock the Anthropic SDK (Claude) in Jest and Vitest](https://icernigoj.github.io/llmao/mock-anthropic-sdk.md): Mock @anthropic-ai/sdk in your tests with llmao. Messages, streaming, extended thinking, tool use and real Anthropic errors, with no API key. - [How to test the Vercel AI SDK without API keys](https://icernigoj.github.io/llmao/test-vercel-ai-sdk.md): Test generateText, streamText, generateObject and tool-calling agents built with the Vercel AI SDK, using llmao as a mock provider. Works with @ai-sdk/openai and @ai-sdk/anthropic. - [How to test rate limits (429), retries and outages of LLM APIs](https://icernigoj.github.io/llmao/simulate-llm-errors.md): Simulate OpenAI and Anthropic rate limits, 500 errors and timeouts in your tests, with the SDKs' real error classes and retry-after headers, to check your retry and fallback logic. - [Test code that calls OpenAI or Claude with node:test, Mocha or any runner](https://icernigoj.github.io/llmao/test-llm-code-any-runner.md): Point the official OpenAI and Anthropic SDKs at a local fake LLM server with OPENAI_BASE_URL and ANTHROPIC_BASE_URL. No module mocking, no code changes, works with any test runner. - [A fake OpenAI-compatible API server for local development and CI](https://icernigoj.github.io/llmao/fake-openai-api-server.md): Run a local server that speaks the OpenAI and Anthropic APIs (chat completions, messages, embeddings, streaming) for development, demos and CI, from any language. No API key. ## Optional - [README](https://github.com/icernigoj/llmao/blob/main/README.md): full reference, including the joke models (lmao-safe, lmao-o1-overthinker…) and agentify() - [npm package](https://www.npmjs.com/package/llmao) - [Full docs in one file](https://icernigoj.github.io/llmao/llms-full.txt)