Skip to content
cosmodev ~/tools/mock-llm-responder

모의 LLM 응답기

AI & Agents

결정론적인 모의 LLM API 응답을 생성합니다. 채팅 완성 JSON, 청크 타이밍이 포함된 SSE 이벤트 스트림, 재생용 curl까지 제공되어 API 키 없이 클라이언트를 테스트할 수 있습니다.

200 OK
{
  "id": "chatcmpl-mock-821bae6b",
  "object": "chat.completion",
  "created": 1735689600,
  "model": "mock-gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello, mock model!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 5,
    "total_tokens": 10
  }
}
청크: 1첫 바이트: 20 ms청크 간: 25 ms

(문서는 영어)

What it does

The Mock LLM Responder generates deterministic mock LLM API responses for testing clients. Pick a scenario - echo, canned answer, streamed poem-ish lorem, HTTP 429 rate limit, HTTP 500 server error, or slow chunks - and it produces the OpenAI-style chat completion JSON, the SSE event stream (data: lines with a [DONE] terminator and chunk timing markers), and a curl command that replays the request against a local stub. No API key, no account, no network: everything is computed in your browser from a fixed seed, so the same configuration always produces byte-identical output - exactly what a reproducible client test suite needs.

How to use it

  1. Choose a Scenario from the dropdown (e.g. Streamed lorem for a chunked stream, Error 429 to test backoff).
  2. Set the Model name and Max tokens cap your client will send.
  3. Type the User prompt - the echo scenario returns it verbatim as the assistant message.
  4. Switch the Output tabs between Completion JSON, SSE stream, and curl, and copy whichever you need.
  5. Use the timing readout (first byte / inter-chunk) to make your stub sleep like a real model, or Copy share link to send the exact configuration to a teammate.

Examples

Echo scenario (default settings) - completion JSON:

{
  "id": "chatcmpl-mock-821bae6b",
  "object": "chat.completion",
  "created": 1735689600,
  "model": "mock-gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello, mock model!" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 5, "completion_tokens": 5, "total_tokens": 10 }
}

Streamed lorem - SSE stream (abridged). The leading : comment is the chunk timing marker:

: mock scenario=streamed-lorem first-byte=60ms inter-chunk=40ms

data: {"id":"chatcmpl-mock-36156cc1","object":"chat.completion.chunk","created":1735689600,"model":"mock-gpt-4o-mini","choices":[{"index":0,"delta":{"role":"assistant","content":"comet nebula prism comet "},"finish_reason":null}]}

data: {"id":"chatcmpl-mock-36156cc1","object":"chat.completion.chunk","created":1735689600,"model":"mock-gpt-4o-mini","choices":[{"index":0,"delta":{"content":"vector prism lumen\nvector "},"finish_reason":null}]}

...

data: {"id":"chatcmpl-mock-36156cc1","object":"chat.completion.chunk","created":1735689600,"model":"mock-gpt-4o-mini","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":5,"completion_tokens":63,"total_tokens":68}}

data: [DONE]

Error 429 - completion JSON:

{
  "error": {
    "message": "Rate limit reached for the mock model. Please retry after 1 second.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}

curl tab - replay the request against a local stub on port 8080:

# Local stub: reply 200 with the body shown in the JSON tab.
curl -s http://localhost:8080/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"mock-gpt-4o-mini","messages":[{"role":"user","content":"Hello, mock model!"}],"max_tokens":64}'

Good to know

  • Deterministic by design: ids, lorem text, and timestamps come from a seed derived from your scenario, model, and token cap - never from the clock or Math.random(). Same settings in, same bytes out. The created field is the fixed epoch 1735689600 (2025-01-01).
  • Chunks reassemble exactly: every SSE delta’s content, concatenated, equals the completion’s message content - so you can assert stream parsing against the JSON tab.
  • Token math: ~4 characters per token, floor of 1; hitting the Max tokens cap flips finish_reason to "length".
  • Private: runs 100% client-side - no request leaves your browser.
  • Related tools: LLM Cost Calculator, Token Estimator, HTTP Methods Tester.
소스 코드14개 언어

100% 클라이언트 측 · 데이터는 브라우저 밖으로 나가지 않습니다. 도움이 되었나요? 팀원에게 공유해 보세요.