aimock is a free, open source api development & testing project written in TypeScript and released under MIT. It has 930 GitHub stars, 71 forks and 1 open issues, and was last pushed 5 hours ago. On this registry it ranks #89 of 103 tracked projects in API Development & Testing, with 5 head-to-head comparisons available. It gained 4 stars over the last 3 tracked days.

What is aimock?

aimock is a TypeScript mock server that makes every AI provider, protocol, and service an application talks to answer on one local port, built for developers who need deterministic tests of LLM-backed software without API keys, network calls, or surprise bills.

What it is

aimock is mock infrastructure for AI application testing, published under the MIT licence by CopilotKit as the npm package @copilotkit/aimock. It lives in the TypeScript and Node.js ecosystem and presents itself as one package, one port, and zero dependencies. A single process stands in for the whole surface of a modern AI application: LLM providers, image generation and editing, text-to-speech, transcription, audio translation and generation, video generation, embeddings, MCP tools, A2A agents, AG-UI event streams, vector databases, search, rerank, and moderation. The suite is split into named mocks — LLMock, MCPMock, A2AMock, AGUIMock, VectorMock, and Services — that can be composed programmatically or started together.

The concrete problem it solves is test dependence on live third-party services. Instead of pointing a client at real OpenAI, Claude, Gemini, Bedrock, Azure, Vertex AI, Ollama, Cohere, or OpenRouter endpoints, a developer points SDKs at a local base URL such as ${mock.url}/v1 and sets a placeholder key. The same substitution applies to hosted vector databases, Tavily search, Cohere rerank, OpenAI moderation, and ElevenLabs TTS. The thing being replaced is the live API call itself, along with the accounts, keys, quota, latency, and billing that come with it.

Key capabilities

  • LLMock answers for OpenAI Chat, Responses, and Realtime (both GA and Beta), Claude, Gemini REST/Live/Interactions/Embeddings, Bedrock, Azure, Vertex AI, Ollama chat and embeddings, Cohere chat and embed, OpenRouter chat and router, and ElevenLabs TTS.
  • MCPMock serves MCP tools, resources, and prompts with session management, while A2AMock covers the agent-to-agent protocol with SSE streaming and AGUIMock emits AG-UI agent-to-UI event streams for frontend testing.
  • VectorMock exposes Pinecone, Qdrant, and ChromaDB compatible endpoints, and the Services mock covers Tavily search, Cohere rerank, OpenAI moderation, and ElevenLabs TTS.
  • The whole suite runs on one port with npx @copilotkit/aimock --config aimock.json, or through the programmatic API for composing only what a test needs.
  • Record and Replay proxies real APIs, saves the responses as fixtures, and replays them deterministically without network access.
  • Timing-aware recording captures per-frame arrival timestamps, and replay reproduces approximate timing from the recorded TTFT and inter-frame cadence, with a configurable --replay-speed multiplier. Chunk count on replay may differ from the recording; TTFT and average pace are what is preserved.
  • Recorded token usage and cost come from the final usage frame of a streaming completion, so fixtures can support cost assertions.

Who uses it and how

  • Frontend teams testing agent-to-UI behaviour use AGUIMock to drive AG-UI event streams without running a live agent backend.
  • Test suites and CI pipelines use Record and Replay fixtures so runs stay deterministic and offline, with no provider keys present in the environment.
  • Teams that assert on token usage and cost replay recorded completions whose usage frame was captured during recording.
  • Developers integrating MCP tools or agent-to-agent flows exercise those protocols against MCPMock and A2AMock, including SSE streaming.
  • Retrieval pipelines are tested against VectorMock's Pinecone, Qdrant, and ChromaDB endpoints alongside the search and rerank services.

Getting started

Install with npm install @copilotkit/aimock, then construct new LLMock({ port: 0 }), register responses such as mock.onMessage("hello", { content: "Hi there!" }), and call await mock.start(). To run the full suite instead, use npx @copilotkit/aimock --config aimock.json.

How it compares

No list of paid products that aimock replaces, and no comparable tools, are named in the facts available here, so it stands alone in this registry rather than being positioned against alternatives.

When to use it — and when not

Provider environment variables such as OPENAI_BASE_URL and OPENAI_API_KEY must be set before importing or constructing the client, because many SDKs cache the base URL at construction time; a client built first will call the real API and incur charges. Replay is approximate timing, not per-token fidelity, and the package was renamed from @copilotkit/llmock to @copilotkit/aimock in v1.7.0 while the exported class remains LLMock for back-compat, which can confuse newcomers. Anyone needing byte-exact streaming reproduction or per-token timing should not rely on replay for that purpose.

project readme (upstream, from github) — read inline

aimock

Mock infrastructure for AI application testing — point your SDK at one local port and every provider, protocol, and service answers deterministically.

Quick start · The suite · Record & replay · Docs

npm Unit Tests Drift Tests License: MIT

https://github.com/user-attachments/assets/76815122-574a-48e1-b275-edae0a014667

One package, one port, zero dependencies. LLM APIs, image generation and editing, text-to-speech, transcription, audio translation and generation, video generation, embeddings, MCP tools, A2A agents, AG-UI event streams, vector databases, search, rerank, and moderation — no keys, no network, no surprise bills.

Quick Start

npm install @copilotkit/aimock
// The class is still named `LLMock` for back-compat after the v1.7.0 package
// rename from `@copilotkit/llmock` to `@copilotkit/aimock`.
import { LLMock } from "@copilotkit/aimock";

const mock = new LLMock({ port: 0 });
mock.onMessage("hello", { content: "Hi there!" });
await mock.start();

// Set env BEFORE importing/constructing the OpenAI (or other provider) client.
// Many SDKs cache the base URL at construction time — if the client is built
// before these are set, it will talk to the real API (surprise bills) instead
// of aimock.
process.env.OPENAI_BASE_URL = `${mock.url}/v1`;
process.env.OPENAI_API_KEY = "mock"; // SDK requires a value, even when base URL is mocked

// ... run your tests ...

await mock.stop();

The aimock Suite

aimock mocks everything your AI app talks to:

Tool What it mocks Docs
LLMock OpenAI (Chat/Responses/Realtime GA+Beta), Claude, Gemini (REST/Live/Interactions/Embeddings), Bedrock, Azure, Vertex AI, Ollama (chat/embeddings), Cohere (chat/embed), OpenRouter (chat/router), ElevenLabs TTS Providers
MCPMock MCP tools, resources, prompts with session management MCP
A2AMock Agent-to-agent protocol with SSE streaming A2A
AGUIMock AG-UI agent-to-UI event streams for frontend testing AG-UI
VectorMock Pinecone, Qdrant, ChromaDB compatible endpoints Vector
Services Tavily search, Cohere rerank, OpenAI moderation, ElevenLabs TTS Services

Run them all on one port with npx @copilotkit/aimock --config aimock.json, or use the programmatic API to compose exactly what you need.

Features

  • Record & Replay — Proxy real APIs, save as fixtures, replay deterministically forever
  • Timing-aware recording and replay — Recorded fixtures capture per-frame arrival timestamps; replay uses recorded timings for approximate timing reproduction based on recorded TTFT and inter-frame cadence (replay chunk count may differ from recording — TTFT and average pace are preserved, not per-token fidelity) with configurable --replay-speed multiplier
  • Recorded token usage and cost — Recording captures the final usage frame of a streaming completion, so replayed fixtures serve real prompt_tokens / completion_tokens instead of a length estimate; OpenRouter's provider-reported usage.cost and its cost_details / *_tokens_details breakdowns are captured too, so an app that bills from real provider cost can e2e-test its wallet path from a tape
  • Multi-turn Conversations — Record and replay multi-turn traces with tool rounds; match distinct turns via turnIndex, hasToolResult, toolCallId, toolResultContains (gate on the tool-result payload), sequenceIndex, systemMessage (gate on host-supplied agent context), or custom predicates
  • 14 providers across 16 API surfaces — OpenAI Chat, OpenAI Responses, OpenAI Realtime (GA + Beta shim), Claude, Gemini REST, Gemini embedContent, Gemini Live, Gemini Interactions, Azure, Bedrock, Vertex AI, Ollama (chat + embeddings), Cohere (chat + embed), OpenRouter (chat + router failover), BytePlus Ark (OpenAI-compatible chat + images under /api/v3), ElevenLabs TTS — full streaming support
  • Multimedia APIsimage generation (DALL-E, Imagen), image editing (/v1/images/edits), text-to-speech (OpenAI + ElevenLabs), audio transcription, audio translation (/v1/audio/translations), video generation, OpenRouter video generation (/api/v1/videos with async job lifecycle), Google Veo video generation (:predictLongRunning + /v1beta/operations async lifecycle), Grok Imagine video generation (/v1/videos/generations with async job lifecycle), BytePlus Ark video generation (Seedance, /api/v3/contents/generations/tasks with async task lifecycle), fal.ai (image / video / audio with queue lifecycle)
  • MCP / A2A / AG-UI / Vector — Mock every protocol your AI agents use
  • Chaos Testing — 500 errors, malformed JSON, mid-stream disconnects at any probability; read, set and clear the rates at runtime via GET / POST / DELETE /__aimock/chaos, scoped to the caller's X-Test-Id so one test cannot destabilise the suite running beside it
  • Request journalGET /__aimock/journal returns every recorded request, filterable by path, method, status, service and testId with limit / offset paging and an X-Total-Count header carrying the pre-pagination total
  • Per-Request Strict ModeX-AIMock-Strict header overrides the server-level --strict flag per request (true/1 = strict, false/0 = lenient)
  • Context-Based Fixture RoutingX-AIMock-Context header scopes fixtures per integration; fixtures with match.context only match requests carrying that context, fixtures without it remain shared
  • Drift Detection — Daily CI validation against real APIs
  • Streaming Physics — Configurable ttft, tps, and jitter
  • WebSocket APIs — OpenAI Realtime (GA protoco

readme truncated — read the full docs on github

Frequently asked questions

Is aimock free to use?

aimock is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does aimock do?

Mock everything your AI app talks to — LLM APIs, MCP, A2A, AG-UI, vector DBs, search. One package, one port, zero dependencies.

What is aimock written in?

aimock is primarily written in TypeScript. Its source is publicly available at https://github.com/CopilotKit/aimock, and it has 930 GitHub stars.