bug: `jan serve` rejects every client request with 401; with `--api-key` its own model load fails (0.8.4, Windows)
Author: nkuglandCreated Sep 28, 2026Updated Sep 28, 2026
Title: bug: jan serve rejects every client request with 401; with --api-key its own model load fails (0.8.4, Windows)
Version: Jan 0.8.4 (jan --version: jan 0.8.4); llama.cpp backend b9967, win-cuda-13-common_cpus-x64
Describe the Bug
A model served with jan serve cannot be used by any external client.
- Without
--api-key, the model loads, but/v1/chat/completionsreturns401 Invalid API Keyboth with noAuthorizationheader and with a bearer key.jan serve --helpsays--api-keydefaults to""(no key required). - With
--api-key <key>,jan servefails to load the model: its own/models/loadrequest to the router is rejected with 401.
LLAMA_API_KEY and MLX_API_KEY are not set in the shell. The Jan desktop app's Local API Server on the same machine works: the same request with its configured key returns 200.
Steps to Reproduce
- Quit the Jan desktop app (its Local API Server also uses port 6767).
- Confirm no key is set in the environment:
echo "LLAMA=$env:LLAMA_API_KEY MLX=$env:MLX_API_KEY"printsLLAMA= MLX=. jan serve Qwen3_5-9B-IQ4_XS→✓ Qwen3_5-9B-IQ4_XS ready · http://127.0.0.1:6767- In another terminal, with no key:→
curl.exe -s -w "`n%{http_code}`n" -H "Content-Type: application/json" -d '{\"model\":\"Qwen3_5-9B-IQ4_XS\",\"messages\":[{\"role\":\"user\",\"content\":\"Hi\"}],\"max_tokens\":1}' http://127.0.0.1:6767/v1/chat/completions{"error":{"message":"Invalid API Key","type":"authentication_error","code":401}} - The same request with
-H "Authorization: Bearer <key>"→ the same 401. - Stop the server, then run
jan serve Qwen3_5-9B-IQ4_XS --api-key <key>→ the model fails to load (log below).
Expected Behavior
- Without
--api-key: requests without a key succeed, per the documented default of"". - With
--api-key <key>: the model loads, and clients sendingAuthorization: Bearer <key>succeed. This is the usage shown in #7575 (jan serve ... --api-key sk-local).
Screenshots / Logs
With --api-key:
✗ Failed to load Qwen3_5-9B-IQ4_XS: Router /models/load returned 401 Unauthorized: {"error":{"message":"Invalid API Key","type":"authentication_error","code":401}}jan serve Qwen3_5-9B-IQ4_XS -v (no --api-key): the router command line has no --api-key, yet the router enforces a key:
[... INFO tauri_plugin_llamacpp::router] Router argv: ["--models-preset", "C:\\Users\\nate\\AppData\\Roaming\\Jan\\data\\llamacpp\\router.preset.ini", "--models-max", "0", "--host", "127.0.0.1", "--port", "6767"]
[... INFO tauri_plugin_llamacpp::router] [llamacpp-router] ... I srv llama_server: listening on http://127.0.0.1:6767Additional context
- In #8333 (Jan CLI 0.8.2, Linux),
--api-key 1234appears in the router command line ("--api-key", "1234"), and the router warns thatLLAMA_API_KEY environment variable is set, but will be overwritten by command line argument --api-key. In 0.8.4 no--api-keyappears in the router command line. The router may be getting a key throughLLAMA_API_KEYthat clients cannot know. - Workaround: use the desktop app's Local API Server (port 6767, key from Settings), which returns 200. I changed the port from the default 1337 to match a previous script's settings.
Operating System
- Windows 11 Pro Version 25H2 Installed on 3/15/2025 OS build 26200.9550 Experience Windows Feature Experience Pack 1000.26100.372.0
Source: janhq/jan