llmao

A fake LLM for tests, demos and fun

Just as wrong.
Way cheaper.

It streams, reasons, calls tools and confidently hallucinates, powered by regex. Swap it in for OpenAI, Anthropic or the Vercel AI SDK in your tests, and stop paying for flaky CI.

Install
$ npm i -D llmao
  • No API key
  • Zero dependencies
  • MIT
Works with
Mock LLMs in your tests Swap openai or @anthropic-ai/sdk for llmao with one line. Script the answers and assert on what your app sent. Read the guide → 429 Test rate limits and outages Real 429s, 500s and timeouts, thrown as the SDKs' own error classes. See your retry logic actually work. Read the guide → Test AI SDK agents generateText, streamText, generateObject and tool calls, scripted step by step. Read the guide → Any language, any runner An OpenAI and Anthropic compatible server. npx llmao serve and point your SDK at it. Read the guide →

Try it

Pick a model and ask anything. It will answer with total confidence.

Try the overthinker with "what is 2 + 2?", or ask lmao-safe to reverse a word.

Mock LLMs in your tests

Swap the SDK your app already uses for llmao, script the answers, simulate rate limits and outages, and check what your app sent. No API keys in CI, no flaky tests, no bill.

Mock openai with one line. Your app keeps calling new OpenAI(). Read the guide →

jest.mock('openai', () => require('llmao/openai'));

import * as llmao from 'llmao/testing';
import { classify } from './support'; // uses new OpenAI() inside

beforeEach(() => llmao.reset());

test('classifies shipping tickets', async () => {
  llmao.configure({ script: [{ when: /never arrived/i, text: 'shipping' }] });

  expect(await classify('My order never arrived')).toBe('shipping');
  expect(llmao.lastCall().prompt).toBe('My order never arrived');
});

Guides

Everything a real LLM does