install-newt now asks for the API's public URL first (--api-url) and records it; it names the Pangolin resource and refuses an endpoint on the same host. expose-dashboard records only that the dashboard is public. One rule (opencode.client_targets) decides which opencode-install.sh commands are shown -- local only without a tunnel; internet and local with one; internet only once the dashboard is public -- and setup's closing message, `llmhost opencode-config` and the dashboard's Connect dialog all use it. Setup's offer to install opencode now goes through opencode-install.sh --install-only, a new mode that only installs opencode; this machine's own provider is still configured by llm-host, which keeps it in sync on every switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| llmhost | ||
| tests | ||
| tools | ||
| .gitignore | ||
| install.sh | ||
| opencode-install.sh | ||
| README.md | ||
llm-host
Turn a machine with a decent GPU into a local LLM server for coding agents like opencode. llm-host detects the hardware, picks the models (and the right build of each) that fit, installs the inference backend, and runs it as a background service with a web dashboard.
Either way you get the same OpenAI-compatible API (with an API key) on port 1134 and a dashboard on port 11340. The model server itself listens on localhost (port 1135), behind a small proxy on 1134 that checks the key, answers to the model's names, applies the dashboard's reasoning setting and times each request — the same proxy on both platforms, so clients and the dashboard see one API. Everything installs into your home directory; no sudo, Docker or system CUDA toolkit needed.
Install
On the machine that will run the models:
/bin/bash -c "$(curl -fsSL https://git.neilbantoc.dev/pub/llm-host/raw/branch/main/install.sh)"
It shows the plan (which models fit, which build, how much context) and asks before installing.
Pass setup options after --:
/bin/bash -c "$(curl -fsSL https://git.neilbantoc.dev/pub/llm-host/raw/branch/main/install.sh)" -- --yes --default ornith-1.5-35b
Ports: the API defaults to 1134 and the dashboard to 11340. On a first install a busy default moves to the
next free port; after that the ports are saved and never move on their own (clients are configured with them).
Change them with llmhost setup --api-port <port> --web-port <port>. On a Mac, MLX also uses the API port + 1.
Preview what a machine would get without installing anything (needs only Python 3.11+):
git clone https://git.neilbantoc.dev/pub/llm-host.git && cd llm-host
PYTHONPATH=. python3 -P -m llmhost plan # this machine
PYTHONPATH=. python3 -P -m llmhost plan --simulate nvidia:24:8.9 # an RTX 4090
PYTHONPATH=. python3 -P -m llmhost plan --simulate apple:64 # a 64 GB Mac
Use
| Command | |
|---|---|
llmhost status |
service state and URLs |
llmhost models |
models that fit this machine (* = active) |
llmhost switch <model> |
serve a different model (downloads it first if needed) |
llmhost download <model> |
download ahead of time |
llmhost watch |
download and loading progress, until the model is ready |
llmhost logs -f |
follow the model server log (--web for the dashboard's, --newt for the tunnel's) |
llmhost start / stop / restart |
control the model server (stop frees the GPU) |
llmhost key |
print the API key |
llmhost install-newt |
optional: reach the API from the internet through a Pangolin tunnel; the dashboard stays local (see Reaching it from the internet) |
llmhost install-oidc |
optional: sign in to the dashboard through an OIDC provider instead of the API key |
llmhost install-otp |
optional: pair authenticator apps; their codes also open the dashboard (--show to add another device) |
llmhost expose-dashboard |
walk through publishing the dashboard through the tunnel, once it has a sign-in of its own |
llmhost remove-newt / remove-oidc / remove-otp |
undo the matching install-* |
llmhost opencode-setup |
install opencode here if needed and connect it to this server |
llmhost opencode-config |
print what to add to opencode on another machine |
llmhost opencode-remove |
take llm-host back out of this machine's opencode config (--host for a retired remote server, --all for every one) |
llmhost update |
pull the latest llm-host and re-plan (--backend also upgrades vLLM/MLX) |
llmhost uninstall [--purge] [--models] [--keep-key] |
remove services, backends and this machine's opencode provider; asks before deleting downloaded models (--models deletes without asking). --purge --keep-key keeps the API key so a reinstall reuses it |
The dashboard (http://<host>.local:11340) shows the active model, throughput, KV cache, GPU utilization,
temperature and power with 10-minute charts, the server log, and buttons to switch models or stop the server.
It also lists the last 20 finished requests, each split into its two phases at the first generated token:
prompt tokens with the seconds and rate of the prefill, then generated tokens with the seconds and rate of
the generation. A request that didn't stream has no first-token mark, so its prompt seconds read — and its
whole duration counts as generation.
Reaching it from the internet
A plain install is LAN-only, and the dashboard asks for the API key. Going further is a few separate, optional steps, so the API can go online without the dashboard:
| step | what it adds |
|---|---|
llmhost install-newt |
the API, online through a tunnel; the dashboard stays on your LAN |
llmhost install-oidc |
dashboard sign-in through your OIDC provider, replacing the API key |
llmhost install-otp |
dashboard sign-in with codes from an authenticator app, alongside (or instead of) the key |
llmhost expose-dashboard |
a walkthrough for putting the dashboard online too, once it has one of those sign-ins |
The API: install-newt
newt dials out to your Pangolin server, which serves HTTPS on your domain. Nothing on this machine is opened to the internet, and no port is forwarded. newt runs as a third user service, in userspace (no root). It's a pinned release, checked against its sha256 before it's installed.
Create a Newt site in Pangolin (Sites → Add Site → Newt, which gives an endpoint, ID and secret), then:
llmhost install-newt --api-url https://llm-api.example.com \
--endpoint https://pangolin.example.com --newt-id <site id>
--api-url is where clients will reach the API: a domain you'll add as a resource on Pangolin, not Pangolin's own
address (--endpoint). It's asked for first, because llm-host uses it to describe the resource and to print the
right opencode-install.sh command everywhere it gives one.
It asks for the site secret, or reads $LLMHOST_NEWT_SECRET; it's never taken as a flag, so it stays out of shell
history. The secret is stored in ~/.config/llm-host/newt_secret (mode 600) and handed to newt in its environment
at start, never written into a service file or config.json. Running it again changes only what you give it.
Then add one HTTP resource in Pangolin, for the API: the --api-url host → <this machine's LAN IP>:<API port>,
with Pangolin's own authentication off, since llm-host checks the API key. Point it at the LAN IP, not
localhost, which llm-host treats as local. Clients use https://<API host>/v1 with the key; for opencode, see
opencode-install.sh.
Dashboard sign-in: install-oidc and install-otp
Out of the box the dashboard takes the API key, the same key you hand to API users. That's fine on your LAN, but anyone holding the key could also stop, start or switch the model from the dashboard. Before the dashboard goes online, give it a sign-in of its own.
OIDC (llmhost install-oidc) replaces the key with sign-in through your identity provider, limited to the
groups or usernames you allow. Register a confidential client using client_secret_basic, the authorization-code
flow with PKCE (S256), scopes openid profile email groups, and the redirect URI https://<dashboard host>/auth/callback:
llmhost install-oidc --public-url https://llm-dash.example.com \
--issuer https://auth.example.com --client-id <client id from the provider> \
--allow-group llm-admins # and/or --allow-user <username>; repeatable
It asks for the client secret (or reads $LLMHOST_OIDC_SECRET) and checks the provider's discovery document.
Sign-in happens at the public URL, and visits by any other address are sent there, so the dashboard must be
reachable at that URL; see expose-dashboard. For Authelia, the client looks like this:
identity_providers:
oidc:
clients:
- client_id: llm-host
client_name: llm-host dashboard
client_secret: '$pbkdf2-sha512$...' # authelia crypto hash generate pbkdf2 --random
public: false
authorization_policy: two_factor
require_pkce: true
pkce_challenge_method: S256
redirect_uris: ['https://llm-dash.example.com/auth/callback']
scopes: [openid, profile, email, groups]
response_types: [code]
grant_types: [authorization_code]
token_endpoint_auth_method: client_secret_basic
How OIDC sign-in behaves:
- Only listed people get in. A person must be in an allowed group or have an allowed username
(
preferred_username, falling back to email). Groups come from userinfo. - The ID token is checked. Its issuer, audience, expiry and nonce must match. It arrives directly from the token endpoint over TLS, which OIDC allows in place of verifying its signature.
Authenticator codes (llmhost install-otp) need no provider. It shows a QR code in the terminal; scan it with
any authenticator app, then type the code it shows to confirm. After that, the dashboard's sign-in also accepts a
current 6-digit code. To add another phone later, llmhost install-otp --show shows the same pairing again. Each
code works once, and after 5 wrong codes in 5 minutes codes are refused for a while. The limit is global, because
behind a tunnel every request comes from the same address. Codes are TOTP: SHA-1, 6 digits, 30 seconds, the
defaults every app supports. The secret is kept in ~/.config/llm-host/otp_secret (mode 600). The API key keeps
working on the dashboard too, until expose-dashboard offers to turn it off there.
For both, sessions are HttpOnly, SameSite=Lax cookies, Secure behind HTTPS. They last 12 hours and are held in
memory, so restarting the dashboard signs everyone out. State-changing requests must come from the dashboard's own
page. While OIDC is on, it's the only way in, and codes come back with remove-oidc.
The dashboard: expose-dashboard
llmhost expose-dashboard won't start until install-newt is done. It then checks the dashboard's sign-in:
- OIDC: fine.
- Authenticator codes: it offers to stop the API key opening the dashboard.
- The key alone: it explains the risk and asks before going on (
--forceskips the question).
Then it describes the Pangolin resource to add (the dashboard's host → <LAN IP>:<dashboard port>) and, once you
press Enter, checks the public URL reaches this dashboard. It records only that the dashboard is public, not where.
Which address clients are given
Setup's closing message, llmhost opencode-config and the dashboard's Connect dialog all print the
opencode-install.sh command, for these addresses:
| state | commands shown |
|---|---|
| no tunnel | the local network (http://<host>.local:<API port>) |
install-newt done, dashboard local |
the internet (--api-url), then the local network |
expose-dashboard done |
the internet only, since the dashboard is then seen from outside |
llmhost status shows the tunnel and sign-in settings. setup and update keep them, and update moves newt to
a newly pinned release. Each step has an undo: remove-newt, remove-oidc, remove-otp.
Connecting opencode
On the server itself, setup handles it: if opencode isn't installed it offers to install it, through
opencode-install.sh --install-only like any other machine (which runs opencode's official installer, into
~/.opencode/bin), then adds an llmhost provider to ~/.config/opencode/opencode.json
pointing at http://localhost:<api port>/v1 and reading the key straight from llm-host's key file. It shows up
in opencode as LLMHost (Local). Other providers and your default model are left alone; the first change backs
the file up as opencode.json.before-llmhost.
llmhost update keeps the provider's port and model list in sync. Run it on demand with llmhost opencode-setup
(--yes to install without asking); skip it during setup with --no-opencode, or install without asking with --opencode.
A config with comments (.jsonc) is never rewritten, since that would drop them; setup prints the block to paste instead.
On another machine, use opencode-install.sh (below); setup ends by printing the exact command for this
server. To do it by hand instead, run llmhost opencode-config on the server. It prints a provider block and a
one-liner that copies the API key over. That block is named LLMHost (<the server's hostname>) — e.g. LLMHost (mybox.local)
— under the provider id llmhost-<shorthost>.
On any machine, in one step, run opencode-install.sh from this repo. It needs only the API's address and
the key, not the dashboard or llm-host, so you can hand it to people who reach just the API, such as through a
tunnel that exposes the API alone. The dashboard's Connect button shows the command with the address filled in:
/bin/bash -c "$(curl -fsSL https://git.neilbantoc.dev/pub/llm-host/raw/branch/main/opencode-install.sh)" -- --url https://<API host>
It checks the server answers with the key, which it asks for without echoing it (or pass --key /
$LLMHOST_API_KEY, at the cost of the key landing in shell history). Then it installs opencode with the official
installer, unless it's already there, saves the key to ~/.config/opencode/llmhost-<host>.key (mode 600), and adds
the provider to opencode.json. Everything else in that file is kept, and it's backed up as
opencode.json.before-llmhost first. It makes the server the default model when you have none; if you do, it asks
first, and --default / --no-default decide without asking. It also drops any key opencode had cached for that
provider. A .jsonc config is never rewritten; the block is printed to paste instead. --remove takes the server
back out. It needs curl and python3.
One opencode, several servers
The two paths use different provider ids, so a single opencode config can point at a local server and any number of remote ones at once, each named after the machine it reaches:
| provider id | shows up as | API key | |
|---|---|---|---|
| local | llmhost |
LLMHost (Local) |
read straight from ~/.config/llm-host/api_key |
| remote | llmhost-<shorthost> |
LLMHost (<host>) |
copied to ~/.config/opencode/llmhost-<shorthost>.key |
Each provider offers a single model, default, rather than every model that fits. One model is loaded at a
time, so a list of them would be a menu of one entry that works and the rest answering 404 model_not_found —
and naming the loaded model would break the client's saved default on the next llmhost switch. default is a
name the API also answers to, so llmhost/default keeps working across switches: the proxy accepts it as an
alias, and /v1/models reports the real slug. The local entry is labelled with whatever is loaded — Default model · Qwen3.8 27B (Local) — and
llmhost switch, the dashboard and llmhost update keep that label current. A config that still points at a
specific model (llmhost/qwen3.8-27b) is migrated to llmhost/default the next time llm-host writes the block.
opencode offers its own low/medium/high effort menu for any reasoning model, so the block carries
variants that switch all three off. The effort level is set on the dashboard, next to the model it applies
to, and the proxy drops whatever a client sends — a chooser in the client would be a menu that silently does
nothing, listing levels the loaded model's template may not even define.
Neither the model nor its reasoning setting is the client's to choose: both change on the dashboard (or with
llmhost switch <name>), because one model is loaded at a time and one setting applies to it.
Which block belongs to this machine is decided by the key-file reference it carries, not by its name. So the
provider is still recognised after you rename it, a remote provider that happens to sit under the llmhost id is
never overwritten (setup takes llmhost-local instead and says so), and uninstall removes only the local
provider — remote ones, and providers llm-host didn't create, are left in place. If a provider's default model
goes away with it, model is repointed at a surviving llm-host provider, and dropped only if there is none.
Retiring a server is the one thing the servers can't do for each other: uninstalling on mybox can't reach the
clients pointing at it. On each client, run llmhost opencode-remove --host mybox.local (or delete the block by
hand if llm-host isn't installed there).
If opencode keeps asking for the API key
opencode caches a provider's key in its own credential store, ~/.local/share/opencode/auth.json, and that copy
wins over opencode.json: when it is stale, opencode fails auth without even sending a request and asks for the
key interactively. llm-host mints a fresh key whenever the config dir is purged, so a cached copy goes stale on
every uninstall --purge + reinstall.
Setup therefore deletes the cached entry for its own provider each time it runs, leaving the {file:...} reference
in opencode.json authoritative — that tracks the key file, so it can't go stale. Other providers' credentials in
that file are never touched. If you hit this on a client machine, delete the provider's entry from auth.json and
let it read the key file again.
To avoid invalidating remote clients in the first place, purge with --keep-key:
llmhost uninstall --purge --keep-key # keeps ~/.config/llm-host/api_key; a reinstall reuses it
Reasoning effort
Reasoning effort is not a backend flag — it's a chat-template argument, read per request, and
what it accepts differs per model. Qwen3.8 27B's template takes enable_thinking plus
reasoning_effort in low/medium/xhigh (note: no high) and raises on anything else;
Ornith 1.5 9B takes only enable_thinking. So the dashboard builds the chooser from the loaded
model's own template, with the level names from catalog.json ("effort": {"levels": [...]}) —
a level the template doesn't know is never offered or sent.
The dashboard is the only place it is set. The proxy puts the setting on every chat completion
and takes the client's own out first — both a top-level reasoning_effort and enable_thinking
or reasoning_effort inside chat_template_kwargs. Template kwargs llm-host has no opinion
about are passed through untouched. Changing the setting takes effect on the next request with no
reload, so the model stays in memory.
Clients are ignored here rather than obeyed because one model is loaded at a time under one
setting, and because a client's menu is generic: opencode offers high, which Qwen3.8's template
raises on, and the user would see every request fail with nothing on their screen to explain it.
This works the same on vLLM and MLX.
How models are chosen
llmhost/catalog.json lists each model with every build of it (FP8, BF16, NVFP4, AWQ, MLX 8/6/4-bit),
its size, and its KV-cache cost per token (measured on real hardware). For each model, llm-host tries
builds in preference order and keeps the first that fits:
weights + ~3 GiB overhead + KV cache for 32k tokens ≤ usable GPU memory
- NVIDIA: usable = VRAM × 0.90 (0.95 if needed), summed over GPUs with tensor parallelism. Builds are
filtered by compute capability (NVFP4 needs Blackwell; FP8 and BF16 need Ampere or newer).
vLLM then sizes the context window to the memory that's actually left (
--max-model-len -1). - Apple Silicon: usable = the GPU's share of unified memory (macOS allows ~67–75% by default,
or
iogpu.wired_limit_mbif you've raised it). MLX keeps an fp16 KV cache, so it's counted double.
--prefer changes the order: balanced (default: FP8 on NVIDIA, 6-bit on Mac), quality (BF16 / 8-bit),
or speed (NVFP4 / 4-bit).
To add a model: add an entry to catalog.json (copy an existing one; vLLM flags such as the tool-call and
reasoning parsers come from the model card or the vLLM recipes), then run
python3 tools/refresh_catalog.py --write to fill in sizes, and llmhost update on each server.
What setup does on Linux + NVIDIA
These avoid problems that come up on a fresh desktop install without sudo:
- vLLM goes in its own venv built on uv's Python (distro Pythons often lack the headers Triton needs).
- vLLM compiles some GPU kernels at startup and needs
nvcc. Setup installs the CUDA compiler from pip, pinned to the CUDA version torch was built for, and assembles a CUDA toolkit directory from the pip wheels. - Kernel builds are limited to one compile job per ~12 GB of RAM (unlimited builds can exhaust memory).
loginctl enable-lingerkeeps the services running when you're logged out (and starts them at boot).
Tests
Stdlib only, no test dependencies, and nothing touches a real install — every suite redirects
LLMHOST_HOME, LLMHOST_CONFIG and XDG_* into a temp dir, and tests/harness.py aborts the
run if any path llmhost could write to resolves outside it.
python3 tests/run.py # every suite
python3 tests/run.py proxy # just the ones matching "proxy"
python3 tests/test_opencode.py # or run one directly
tests/test_opencode.py |
provider naming and ownership, removal, the credential cache |
tests/test_proxy.py |
model names, dropping client reasoning settings, upstream key, streamed-run counting, against a fake server |
tests/test_dashboard.py |
KV parsing, per-run summaries, log collapsing |
tests/test_dashboard_auth.py |
API-key mode, and OIDC sign-in against a fake provider: PKCE, state/nonce/aud/iss/exp checks, allow list, origin check, sign-out |
tests/test_opencode_install.py |
opencode-install.sh against a fake API in a throwaway HOME: new and existing configs, default-model choice, cached-key cleanup, --remove, refusals |
tests/test_newt.py |
install-newt, install-oidc, install-otp, expose-dashboard and their undos against fake services: pinned checksum, secrets kept out of config, output and argv, re-runs |
tests/test_otp.py |
TOTP against RFC 6238, code replay and lockout, the QR encoder against reference matrices, code sign-in on the dashboard |
tests/test_reasoning.py |
effort options matching the real chat templates; the setting surviving an update |
Continuing on an NVIDIA box
This branch was written on Apple Silicon + MLX, then checked on Linux (vLLM 0.33.0, RTX PRO 6000
Blackwell, qwen3.8-27b) on 2026-11-03. python3 tests/run.py passes on either platform (the
suites are hermetic and don't need a GPU), so run that first.
Verified on the NVIDIA box:
- vLLM runs behind the proxy (
backends/proxy.py), on127.0.0.1:1135with its own API key, which the proxy sends on. From the LAN: a wrong key gets 401, the inner port is unreachable,"model":"default"is answered, an unknown model gets the proxy's404 model_not_found, and/v1/modelslists only the slug. - Reasoning chooser: offers what Qwen3.8's template accepts; setting "Thinking off" from the dashboard took effect on the next request with no restart.
- Completed-requests table: filled from the proxy, with prompt tokens net of the prefix cache
(
--enable-prompt-tokens-details) and generated tokens from the usage chunk (a vLLM stream chunk can carry several tokens). - opencode from another machine: streaming and tool calls through the proxy; its generic
highmaps toxhighinstead of failing; the generated block hideshighand addsxhigh. - Dashboard: GPU temperature and power from
nvidia-smi, and KV usage from vLLM's/metrics(read from the inner port).METRIC_REhad been dropped fromweb/server.py, leaving the dashboard stuck on "loading";tests/test_dashboard.pynow covers it.
Still open:
- opencode 1.19 keeps credentials in
~/.local/share/opencode/opencode.db(acredentialtable), notauth.json, soopencode.clear_authno longer finds a stale cached key there. - Power is summed over the GPUs that report it, so on a multi-GPU box a card showing
[N/A]makes the total read low (seen with a stubnvidia-smi, not real hardware). llmhost opencode-removeanduninstall --purge --keep-keypass their hermetic tests on Linux but haven't been run against a real install there.- An existing install picks up the second port on the next restart;
setupchecks it's free, a bare restart doesn't (vLLM fails to bind and the log says so).
Files
| Path | |
|---|---|
~/.local/bin/llmhost |
launcher |
~/.local/share/llm-host/ |
this repo (src/), backend venvs, the assembled CUDA toolkit |
~/.config/llm-host/config.json |
the plan: backend, fitting models, active model, ports |
~/.config/llm-host/api_key |
API key (mode 600) |
~/.config/llm-host/oidc_secret |
OIDC client secret (mode 600), after install-oidc |
~/.config/llm-host/otp_secret |
authenticator-app secret (mode 600), after install-otp |
~/.config/llm-host/newt_secret |
Pangolin site secret (mode 600), after install-newt |
~/.local/share/llm-host/newt/ |
the newt binary, after install-newt |
~/.cache/huggingface/hub/ |
downloaded models |
Linux: ~/.config/systemd/user/llm-host-{model,web}.service |
services (journalctl --user -u llm-host-model) |
macOS: ~/Library/LaunchAgents/dev.llm-host.{model,web}.plist |
services; logs in ~/Library/Logs/llm-host/ |
On macOS the services are launchd agents, so they run while you're logged in.
Limitations
- One model loaded at a time. Asking the API for a different one returns
404 model_not_foundnaming the loaded model, rather than answering with it. - Reasoning effort is set on the dashboard, not by the client. A request's own
reasoning_effort(top-level or inchat_template_kwargs) is dropped and the dashboard's setting applied instead. - AMD (ROCm), Intel and CPU-only machines aren't supported yet.
- The API and dashboard use plain HTTP and are meant for a trusted LAN. Don't forward their ports to the internet;
use
llmhost install-newt, which puts HTTPS in front, and give the dashboard its own sign-in beforeexpose-dashboard. - Everyone using the API shares one key, with no per-person revocation or rate limits.