API reference
Endpoints
LlamaNexus exposes both /ollama/api/* and /openai/v1/* routes, forwarding to llama-server's single OpenAI-compatible router underneath.
| Endpoint | Purpose |
|---|---|
POST /openai/v1/chat/completions |
Streaming SSE chat completion, with tool-calling support |
GET /openai/v1/models |
Model list - real context size, trained context, load status (see below) |
GET /status |
Connection check, plus current RPC worker mode/roster |
POST /ollama/api/pull |
Download a not-yet-present model, streaming progress |
POST /api/set-ctx-size |
Change a model's ctx-size and restart to apply it |
POST /api/eject-model |
Unload a model from the server (keep the file on disk) |
POST /api/remove-model |
Permanently delete a downloaded model |
POST /api/rpc/mode, /api/rpc/workers, /api/rpc/workers/remove |
Toggle single-node/RPC mode, add/remove RPC workers |
How model identifiers work
Models are addressed as repo:tag, e.g. unsloth/Qwen3.5-4B-GGUF:Q4_K_M. LlamaNexus scans the Hugging Face cache and infers a short quant-tag identifier from each cached file's name (Q4_K_M, Q8_0, Q5_K_M, Q4_0, or the filename with its .gguf extension stripped if none of those match).
Both /ollama/api/chat and /openai/v1/chat/completions normalize the request's model field (strips a trailing .gguf/:latest) before forwarding, so a client can request a model by its exact repo:filename.gguf form and it'll still match the router's registered id.
When pulling a model by a short tag that doesn't exactly match a real filename (e.g. Q4_K_M when the real file is model-name-Q4_K_M.gguf), LlamaNexus resolves the real filename against the repo's file listing before downloading. A successful pull restarts llama-server's router and waits (up to 60s) for it to come back up before the request completes.
GET /openai/v1/models detail
Each model entry includes:
context_length- the actualctx-sizethe router is using for that model, sourced from itsrouter.preset.inioverride or the[*]global default. Authoritative.n_ctx_train- the model's max trained context length, read from its GGUF metadata. Purely informational, not necessarily what the model is actually running with. Omitted when it can't be determined.loaded- whether the router currently has that model loaded.
Context size overrides
Open WebUI's per-model num_ctx setting (and the VS Code extension's /ctx-size command) work around llama.cpp allocating its KV cache at model-load time:
- LlamaNexus writes the new
ctx-sizeinto that model's section inrouter.preset.ini. - Restarts the
llama-serverrouter process (it only parses--models-presetonce, at its own startup). - Waits briefly for the router to come back up before the triggering chat request proceeds.
The first message after changing context size pays a short restart cost (typically a few seconds); subsequent messages are unaffected until the value is changed again. A [*] global section in the preset file holds the baseline default for any model without a custom override.
Don't pass --ctx-size as a serve-level argument - it takes precedence over the preset file's per-model values and will silently defeat this mechanism.
POST /api/set-ctx-size
{ "model": "unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M", "ctx_size": 8192 }
Writes the preset, restarts llama-server, waits for the router to come back up, and responds once it has:
{ "ok": true, "model": "unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M", "ctx_size": 8192 }
Model unloading
Open WebUI's "eject" action and Ollama's keep_alive: 0 convention are both detected on /ollama/api/chat and /ollama/api/generate and forwarded to llama-server's router /models/unload endpoint, rather than treated as a real generation request.
POST /api/eject-model
{ "model": "unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M" }
Forwards to llama-server's router /models/unload and responds with { "ok": true, "model": "..." } once done.
Model removal
POST /api/remove-model
Permanently deletes a downloaded model - unlike /api/eject-model (which only unloads it from memory), this removes it from disk entirely.
{ "model": "unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M" }
- Best-effort unloads the model first, so a currently-loaded model isn't left served from a file that's about to disappear.
- Deletes every GGUF file backing that model from the Hugging Face cache - both the snapshot symlink(s) and the blob(s) they point to. A sharded quant has every shard removed together.
- Removes the model's section from
router.preset.ini, if it had a ctx-size override. - Restarts
llama-serverand waits for the router to come back up before responding.
{ "ok": true, "model": "unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF:Q4_K_M", "deleted_files": 1, "freed_bytes": 18350698496, "removed_preset_section": true }
Responds 404 if the model isn't found in the cache.
Known quirks
llama-serverrouter mode is experimental (per llama.cpp's own startup warning) and not recommended for untrusted environments.huggingface_hub's Xet transfer backend produces uneven, bursty progress updates; LlamaNexus disables it (HF_HUB_DISABLE_XET=1) in favor of smooth, evenly-spaced progress reporting, at some cost to raw download speed.- Cancelled or failed downloads can leave orphaned
.incompleteblob files in the Hugging Face cache due to a known upstreamhuggingface_hubbug where resume doesn't work across separate download attempts. LlamaNexus cleans these up automatically on cancellation or failure. - Open WebUI's green "loaded" dot and eject button may not render correctly in all Open WebUI versions due to upstream frontend bugs unrelated to LlamaNexus. Open WebUI 0.9.4 is tested to work; 0.9.6 does not render the indicator correctly, though LlamaNexus's own
/ollama/api/psand unload handling are independently verified to work regardless.