Developer tooling · 2026
Mock AI API
Test the failure paths before your users find them.
$ pipx install mock-ai-api && mock-ai-api
OpenAI-compatible server · http://127.0.0.1:8011
Anthropic-compatible server · http://127.0.0.1:8012
POST /v1/chat/completions gpt-4.1:mock-tool-call 200
POST /v1/messages claude-sonnet-4:mock-anthropic-stream 200 · SSE
POST /v1/chat/completions gpt-4.1:mock-bad-tool-json 200
POST /v1/chat/completions gpt-4.1:mock-429 429
POST /v1/messages claude-sonnet-4:mock-stream-error error event
POST /v1/chat/completions gpt-4.1:mock-503 503
POST /v1/messages claude-sonnet-4:mock-tool-use 200
POST /v1/chat/completions gpt-4.1:mock-401 401
GET /v1/models 200
client = OpenAI(
base_url="http://127.0.0.1:8011/v1",
api_key="mock",
)
def test_backs_off_on_rate_limit():
with pytest.raises(RateLimitError):
client.chat.completions.create(
model="gpt-4.1:mock-429",
messages=[{"role": "user", "content": "hi"}],
)✓ 48 passed in 0.62s · 0 tokens spent
01 / Context
The challenge
AI integrations are expensive and unpredictable to test. Real providers introduce network latency, changing responses, rate limits, and usage costs into test suites that need to be fast and repeatable.
The response
I built a deterministic local server that speaks OpenAI and Anthropic-compatible APIs. Teams can exercise streaming, tools, malformed JSON, and provider errors through the official SDKs without calling a real model.
02 / What it does
Built around the
real work.
- 01
Deterministic OpenAI and Anthropic responses
- 02
Streaming, tool calls, and malformed payload scenarios
- 03
Provider-shaped 400, 401, 429, 500, and 503 failures
- 04
Installable CLI with official SDK compatibility tests
03 / Built with
04 / Read more
The happy path is the least interesting thing to testReal AI providers make it hard to test rate limits, malformed tool calls, and broken streams. So I built Mock AI API, a local stand-in that fails on purpose.