Admin API
Routes for changing a running server: adding response rules, changing chaos, delay and reply settings, and reading the calls your app made. For how to use them in a test, see Using LLMock in tests.
The admin API is on by default. To turn it off, set "admin": false in the server block, or start with --admin=false. It has no login: see Network exposure.
Routes
| Route | What it does |
|---|---|
GET /admin/rules | Lists every rule in the order requests are matched against them |
POST /admin/rules | Adds a rule: { "match", "text" or "content", "in"?, "stopReason"?, "fail"?, "times"? }. Answers 201 with the rule and its id |
DELETE /admin/rules/<id> | Removes one rule added this way |
DELETE /admin/rules | Removes every rule added this way |
GET /admin/chaos | Shows the chaos settings in use, and how many calls were counted and failed |
PATCH /admin/chaos | Changes the chaos settings it is given: enabled, frequency, mode, status, kind, afterChunks |
GET /admin/delay | Shows the response delay in use |
PATCH /admin/delay | Changes the response delay: { "min", "max" } in milliseconds |
GET /admin/settings | Shows the reply settings in use |
PATCH /admin/settings | Changes the reply settings it is given: responseType, maxLoremParas, stream, validateRequests, logRequests, maxLoggedRequests |
GET /admin/requests | The calls your app made, oldest first (see Checking what your app sent) |
GET /admin/requests/<id> | One recorded call, by its x-llmock-request-id |
DELETE /admin/requests | Forgets the recorded calls |
GET /admin/recording | Shows whether the server is recording, and whether that is paused |
PATCH /admin/recording | Pauses or resumes recording: { "paused": true } or { "paused": false } |
POST /admin/reset | Goes back to how the server started: no rules added this way, no recorded calls, the config file's chaos, delay and reply settings, recording not paused, and the chaos call count and the recording counts at 0 |
Rules
- A rule added this way works like a response rule in the config file: the same
match, the same optionalinandexact,stopReasonandfail. It needstext,content(tool calls,claudeonly) orfail. - The reply is given as
textorcontent, never asfile,filesorcontentFile. The server has no login, so a path sent over HTTP would let anyone who can reach it read files from your machine. - Rules added this way are matched before the config file's rules, in the order they were added. To replace a config rule for one test, add a rule with the same
match. - Give a rule
times(a whole number, 1 or more) to have it answer that many matching requests and then remove itself. A call that chaos fails does not count, so the rule is still there for the retry. Withouttimesa rule stays until you remove it or reset.timesis for rules added this way only, not for the config file. - Nothing is saved. The config file is never written, and a restart starts again with the config file's rules only.
- A rule that is not valid gets a
400with{ "error": "..." }and is not added. - Each rule in a listing has
source("runtime"or"config"),id(nullfor a config rule, which can not be removed this way),in("any"or"last"),exact(trueorfalse),content(the tool-call blocks, ornull) andtimes(how many more requests it answers, ornullif it stays). A tool-call rule'sstopReasonis"tool_use".
Chaos, delay and reply settings
PATCHchanges only the settings you send; the others stay as they are. The settings mean what they mean in the config file'schaosandresponseDelay.- A value that is not valid gets a
400and nothing is changed. Nothing falls back to a default, unlike a CLI flag. - Changing chaos settings leaves the call count alone. With
mode: "every", callPOST /admin/resetfirst and thenPATCH /admin/chaos, so the count starts from 0 and you know which call fails. mincan not be more thanmax, and neither can be more than 2147483647 (about 24 days). Send both when you raise the delay from0.PATCH /admin/settingstakes the same names and values as the model preset:responseTypeis"lorem"or"stored",stream,validateRequestsandlogRequestsaretrueorfalse,maxLoremParasis 1 to 1000 andmaxLoggedRequestsis 1 to 100."responseType": "stored"uses the preset'sstoredResponsesFileif it has one, otherwise the texts that come with LLMock. If that file can not be read, the change is refused with a400.streamhas no effect on theclaudetemplate, where each request says whether it wants a stream. On anopenaitemplate it only applies to requests that don't send their ownstream: true/false.- The dashboard shows the settings in use, so a change appears there within 2 seconds. The Admin API box on its Settings page has a Reset button that does the same as
POST /admin/reset. - Everything else (the port, the endpoint, the preset with its template and model name, embeddings, debug mode) still comes from the config file and needs a restart to change.
- While the admin API is on, a preset's
endpointcan not start withadmin/.
Checking what your app sent
GET /admin/requests lists the calls to the chat route and to /v1/embeddings, oldest first. startServer's requests() and lastRequest() give the same entries. Each entry has:
| Field | |
|---|---|
id | The same id as the reply's x-llmock-request-id header |
time | When the call came in (ISO 8601) |
method, path, query | The route, without the query string, and the query string's values |
headers | The request headers, names in lower case. authorization, x-api-key, api-key, x-goog-api-key, proxy-authorization and cookie show as "[redacted]", in case a real key is sent to the mock. So do the query parameters key (as Gemini clients send it), api_key, api-key, apikey and access_token. |
body | The JSON body as sent (null for none) |
valid | false for a call that failed request validation and got a 400 |
streamed | Whether the reply was a stream; null when no reply was sent (a failed validation, or a drop or stall with no stream) |
rule | { "id", "match" } of the response rule that answered or failed the call (id is null for a config rule), or null |
failed | How LLMock failed the call on purpose, { "by": "rule" or "chaos", "kind", "status", "afterChunks" }, or null |
forwarded | When recording: { "status", "saved" } for a call sent on to the provider, else null |
- Filter with
?match=(text the body must contain, case-sensitive, as a rule'smatch),?in=last(look only in the last message, as a rule'sin) and?path=/v1/messages. An unknown or invalid filter gets a400. - Calls are kept whether or not
logRequestsis on, including calls that fail validation. Unlike the request log nothing is written to disk. - The last 500 calls are kept; older ones are dropped.
DELETE /admin/requestsorPOST /admin/resetforgets them, as does a restart. - Like the rules, this is shared by every client of one server. Tests running in parallel against one server should filter by a
matchof their own, or each start their own server.