llm-router prototype cell — the wire contract
The prototype pages at /llm-router/ are fronts for one real server on this
host: llm-router-demo, a Rust/axum cell that tails a router's log over a
WebSocket. This file is the single home for the frames both sides speak, so
sixteen pages and one cell cannot drift.
The domain vocabulary is the real llm-router's
(14x/docker/llm-router/src/session_log.rs): DRQ is its dynamic request
queue, the admission gate that reads drq- when closed and drq+ when open.
Endpoints
| Method | Path | Purpose |
|---|---|---|
GET |
/llm-router/health |
{ok, protocol, interval_ms, drq} — the cell's own state |
WS |
/llm-router/stream?key=<access key> |
the log stream; the socket closes 4401 on a bad key |
POST |
/llm-router/drq |
{enabled: bool} — move the gate without a socket |
In a page, the socket URL is relative to the page origin and the path is
/llm-router/ws (nginx proxies it to the cell's /llm-router/stream):
const url = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/llm-router/ws?key=${encodeURIComponent(key)}`;
Frames
One JSON object per text frame. type is the discriminant; a client ignores
a type it does not know rather than closing, so a page ahead of the cell
still tails.
Server → client, in this order on attach:
{"type":"hello","protocol":1,"interval_ms":10000,"drq":false}
{"type":"drq_state","enabled":false}
{"type":"log","ts":"2026-11-14T23:37:16Z","level":"warn","text":"upstream probe model=glm-5.3 gate=drq- status=401 <api key required>"}
Client → server, the toggle:
{"type":"drq","enabled":true}
Server answers with drq_state and broadcasts a log line naming the gate in
the router's own drq+/drq- vocabulary.
The rejected key is the only error, and it is in-band before the close:
{"type":"error","code":"unauthorized","text":"<api key required>"}
The log line, and its cadence
The cell emits one log line per interval — 10 s by default, and the
hello frame's interval_ms is the authority, never a constant in a page.
That line always carries the literal text <api key required>, which is
the whole point of the page: the router is up, the fleet is answering, and the
one missing thing is the operator's key.
A page must therefore:
- take
ts,level,textfrom alogframe and render them as a terminal line —textverbatim, never reflowed into prose; - keep every line it has received, so the export copy button hands over
the whole transcript it actually saw, oldest first, one line per frame, in
the form
ts level text; - treat the socket's four states —
idle,connecting,open,closed— as visible, because a dead tail that looks live is the one lie a log viewer must never tell.
Access key
The demo key is onefrontier-demo unless the cell is started with
DEMO_ACCESS_KEY. The page's key field is what the visitor types; it is not
looked up, not validated client-side, and never baked into the bundle — the
socket's answer is the only verdict. Empty is not authorized.
Running the cell
cd llm-router-demo && cargo run --release # 127.0.0.1:8399
LOG_INTERVAL_MS=10000 BIND=127.0.0.1:8399 DEMO_ACCESS_KEY=onefrontier-demo \
./target/release/llm-router-demo
nginx carries the door (deploy/nginx/snippets/llm-router-ws.conf), installed
in the vhost as location = /llm-router/ws.