@fezchat/router
v0.0.1
Published
A lean Jev gateway for agent routing and structured judgments.
Readme
Running the Fez Jev gateway
Live endpoint: https://137-184-135-188.sslip.io/v1 on the existing
DigitalOcean fez-router host. The gateway calls TypeSafe's hosted Jev
model. No local model, llama.cpp, or Qwen is required.
The gateway deploys as one bundled JavaScript file with no runtime npm dependencies. Caddy terminates TLS; Node listens on loopback port 8081.
client → HTTPS → Caddy → gateway :8081 → TypeSafe/JevRun from npm
Requires Node.js 20 or newer. This package runs the server; clients call its HTTPS endpoint and do not need to install it. There are zero runtime dependencies and no model downloads.
Set TYPESAFE_API_KEY and ROUTER_API_KEY in the server environment, then:
npx @fezchat/[email protected]The command is fez-router after a global install. It listens on
127.0.0.1:8081 by default; put a TLS reverse proxy in front for remote
clients. /health checks that the gateway is running. Set ROUTER_API_KEY
to require client authentication; without it the gateway accepts unkeyed
requests. Never put the TypeSafe key in client configuration.
API
GET /health: service/configuration status, not a live TypeSafe probe.GET /v1/models: the stablefez-routermodel alias.POST /v1/chat/completions: agent selection using the existing OpenAI tool-call response shape. Accepts one user message, an optional standard Fez router system message, and agent tools with no arguments or a stringtaskargument. The task text is preserved verbatim.POST /v1/judge: structured{ state, questions }passed to Jev. Supportsnoul,choice, andscore, with 1–32 questions per call.
Routing and judgment use Jev exclusively. Unsupported chat formats and streaming return 400. Provider errors or invalid responses return 502; timeouts return 504. A valid no-fit choice is returned unchanged.
Successful routing returns X-Fez-Router-Backend: typesafe and
X-Fez-Router-Confidence. Successful judgment returns X-Fez-Judge-Model.
Logs contain decision metadata, latency, and token counts, never keys or
message content.
Credentials and limits
Keep /etc/fez-router.env root-owned with mode 0600:
ROUTER_API_KEY: authenticates clients; required by the deployment script.TYPESAFE_API_KEY: authenticates the gateway to TypeSafe; required at startup.
Clients receive the gateway URL and gateway credential. The TypeSafe key stays on the server. The existing gateway credential is preserved when deploying.
Optional environment settings: TYPESAFE_MODEL (default jev-1.13.0),
TYPESAFE_TIMEOUT_MS (routing, 2000), JUDGE_TIMEOUT_MS (5000),
RATE_PER_MIN (20 per IP), RATE_BURST (2 concurrent per IP), and
MAX_BODY_BYTES (65536). Both API routes share authentication and limits.
Provision and deploy
Provisioning installs Node, Caddy, and system security prerequisites:
ssh root@<ip> 'HOSTNAME_FOR_TLS=<host> bash -s' < deploy/router/provision-router.shConfigure the two credentials on the server, then deploy:
deploy/router/deploy-router.sh root@<ip>Deployment bundles the shared TypeSafe client, checks credentials without printing them, backs up the current gateway and unit, restarts the gateway, and verifies authenticated routing and judgment through Jev. Failed checks restore the previous gateway and unit.
After successful checks, deployment stops and disables any existing
fez-router.service local model. Model files and binaries remain on disk
for rollback; new provisioning never downloads them.
Operations and rollback
systemctl status fez-router-gateway
journalctl -u fez-router-gateway -f
curl https://137-184-135-188.sslip.io/healthTo restore the preceding deployment on the server:
cp /opt/fez-router/gateway.mjs.prev /opt/fez-router/gateway.mjs
cp /etc/systemd/system/fez-router-gateway.service.prev /etc/systemd/system/fez-router-gateway.service
systemctl daemon-reload
systemctl restart fez-router-gatewayIf restoring a version that used Qwen, its retained service can be
re-enabled with systemctl enable --now fez-router.service.
