Jitterbox can stand in for an LLM provider. Point your SDK's baseURL at a Jitterbox project, and you get
realistic responses that you can make slow, rate-limited, overloaded or broken mid-stream. Nothing reaches the
real provider and no API key is needed (the SDKs require one, so pass any string).
1. Create an LLM endpoint
In a project, create an endpoint and pick a Type:
| Type | Path | SDK baseURL |
|---|---|---|
| OpenAI · Chat Completions | POST /v1/chat/completions |
https://<backend>/p/<projectKey>/v1 |
| OpenAI · Responses | POST /v1/responses |
https://<backend>/p/<projectKey>/v1 |
| Anthropic · Messages | POST /v1/messages |
https://<backend>/p/<projectKey> |
Replace <backend>/p/<projectKey> with your project's mock base URL, shown at the top of the project. The endpoint editor shows a ready-to-paste snippet. Via the API, use kind (OPENAI_CHAT, OPENAI_RESPONSES,
ANTHROPIC_MESSAGES) and llm:
{
"name": "Claude",
"method": "POST",
"pathPattern": "/v1/messages",
"kind": "ANTHROPIC_MESSAGES",
"llm": {
"replyText": "Hello from the mock",
"chunkWords": 3,
"toolCall": { "name": "get_weather", "arguments": "{\"location\":\"Paris\"}" }
}
}
The endpoint replies with replyText, or with a single tool call when toolCall is set. It honours the request's
model (echoed back) and stream flag. Streams use each provider's real event sequence (chat.completion.chunk
plus [DONE]; response.* events; message_start through message_stop).
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ apiKey: "anything", baseURL: "https://<backend>/p/<projectKey>" });
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: "anything", baseURL: "https://<backend>/p/<projectKey>/v1" });
2. Add faults with a scenario
All the usual faults work, plus LLM-specific ones. Each fault uses the usual triggers (always, probability, sequence), and every decision shows up in the inspector.
| Fault | What the client sees |
|---|---|
| HTTP error (no custom body) | The provider's own error format: OpenAI {"error":{"type","code",...}} with x-ratelimit-* and retry-after on 429. Anthropic {"type":"error","error":{"type":"rate_limit_error"|"overloaded_error"|...}} with request-id, plus retry-after on 429. Use 529 for Anthropic "overloaded". A custom body on the rule is sent as-is. |
| Slow first token | Headers arrive immediately, then the stream stalls. On non-streamed calls, the whole response is this much later. |
| Slow stream | Delay between streamed chunks (drawn once per request from min–max). |
| Stream cut | The connection drops after N% of the stream's events: a real network error, not a clean end. |
| Malformed chunk | One streamed event carries truncated JSON. |
| Missing end event | No [DONE] / response.completed / message_stop. |
| Truncated tool arguments | Tool-call arguments cut off mid-JSON. OpenAI reports finish_reason: "length"; Anthropic reports stop_reason: "max_tokens". |
Stream-only faults are skipped (and the decision says so) on non-streamed requests, and LLM faults are skipped on static endpoints. The whole response, streaming included, is capped at 30 s.
Presets in the scenario editor: Rate-limited at peak (429 on every third request), Overloaded provider (30% 529/503 plus a slow first token), Flaky stream (cuts, slow chunks, a malformed event).
X-Jitterbox-Fault and X-Jitterbox-Seed work here too, e.g. X-Jitterbox-Fault: http_error=529.
3. What the real SDKs do (verified)
e2e/llm runs openai@7.62.0 and @anthropic-ai/sdk@1.12.0 against every case:
cd e2e/llm && pnpm install && JITTERBOX_URL=http://localhost:8080 pnpm test.
| Case | OpenAI SDK | Anthropic SDK |
|---|---|---|
| 429 / 529 twice, then OK | Retries automatically (honours retry-after) and succeeds; Jitterbox records 3 attempts |
Same |
| Rate limited / overloaded every time | RateLimitError after 2 retries |
RateLimitError / OverloadedError |
| Stream cut | Over HTTP/1.1, iterating throws TypeError: terminated (not an APIConnectionError). Over HTTP/2, which Node's fetch uses for HTTPS endpoints that offer it (Jitterbox's, and the real API's), the stream ends early with no error. Detect it by the missing finish_reason |
finalMessage() rejects: terminated over HTTP/1.1, "stream ended without producing a Message" over HTTP/2 |
| Malformed chunk | SyntaxError: malformed server-sent event JSON |
AnthropicError (JSON parse error) |
| Missing end event | No error: the stream just ends, so a truncated answer goes unnoticed | finalMessage() rejects ("stream ended without producing a Message") |
| Truncated tool arguments | finish_reason: "length", arguments don't parse |
stop_reason: "max_tokens" |
These are the behaviours worth having tests for in your app: retries that eventually give up, a stream error
that isn't the SDK's own error class, and a silently incomplete OpenAI stream (missing [DONE], or a connection
drop over HTTP/2). The check that works in every case: treat a stream without a finish_reason as incomplete.
The cut is a real connection drop: Jitterbox declares the full Content-Length, then stops short, so proxies
can't paper over it (curl reports exit code 18 over HTTP/1.1, and 92 over HTTP/2). Whether a client raises an
error is up to the client. Verified with Node 26 / undici 8: fetch over HTTP/2 reports a clean end, while
HTTP/1.1 reports terminated.