skip to content

lms CLI and SDKs

lms scripts LM Studio without the GUI, from lms get and lms load --gpu --ttl to lms daemon up, and the Python and TypeScript SDKs add .act() tool loops. Interviewers ask how you would run it headless.

part ofLocal LLM runtimesread it →
on this pageshow

explore

questions

6

How do you run LM Studio on a headless Linux GPU server so that a provisioning script installs it, loads a model and serves it after every reboot?

level: seniorimportance: must knowfreq 12%

answer

  1. the daemon, not the desktop app
  2. llmster since 0.4.0
  3. --yes wherever lms would prompt
  4. pre-flight with --estimate-only
  5. a systemd unit replays the steps

basics

~20 s

Install llmster, LM Studio's GUI-less daemon, start it with lms daemon up, then script lms get --yes, lms load --yes with explicit flags and lms server start, wrapped in a systemd unit so the same sequence reruns at boot.

solid answer

~40 s

Use **llmster**, the GUI-less daemon introduced with LM Studio 0.4.0 and documented as the recommended headless option; the desktop app's run-the-server-on-login mode is meant for machines with a graphical interface. Install it with `curl -fsSL https://lmstudio.ai/install.sh | bash`, which puts `lms` under `~/.lmstudio/bin`. The script then runs `lms daemon up`, `lms get <model> --yes`, a pre-flight `lms load --estimate-only <model> --context-length N`, the real `lms load <model> --yes --gpu max --context-length N --identifier name` and `lms server start`. The documented systemd unit is `Type=oneshot` with `RemainAfterExit=yes`: `ExecStartPre` runs `lms daemon up` and the load, `ExecStart` runs `lms server start`, `ExecStop` runs `lms daemon down`. The server binds to 127.0.0.1 unless you pass `--bind`, and the model has no idle TTL because `lms load` set none.

code

bash · 20 lines
bash
#!/usr/bin/env bash
set -euo pipefail
curl -fsSL https://lmstudio.ai/install.sh | bash
LMS="$HOME/.lmstudio/bin/lms"
MODEL=openai/gpt-oss-20b

"$LMS" daemon up
"$LMS" get "$MODEL" --yes

# lms prints its messages to stderr, and returns normally either way
if ! "$LMS" load --estimate-only "$MODEL" --context-length 16384 --gpu max 2>&1 \
    | grep -q "may be loaded"; then
  echo "estimate fails the resource guardrails" >&2
  exit 1
fi

"$LMS" unload --all
"$LMS" load "$MODEL" --yes --gpu max --context-length 16384 --identifier chat-main
"$LMS" server start
"$LMS" ps

go deeper

for a junior

Recall that LM Studio has a GUI-less daemon called llmster, started with lms daemon up, and that lms server start opens the API on port 1234 by default.

for a middle

Walk through the sequence: install, daemon up, get --yes, load with explicit flags, server start, and explain why each prompt-capable command needs --yes in a script.

for a senior

Show a reboot-safe unit and an idempotent load step, read the estimate verdict from stderr, keep the server on localhost until authentication is on, and plan daemon updates.

for a principal

Judge whether pinned boot-time loads or on-demand loading suit the box, and whether LM Studio's daemon is the right tool here at all versus a dedicated serving stack for multi-user load.

## Two ways to run LM Studio without a person at the screen LM Studio's documentation lists two headless options: | Option | What runs | Fits | |---|---|---| | **llmster** (recommended) | the core of LM Studio packaged as a standalone daemon, no GUI | Linux servers, cloud instances, GPU rigs, CI | | Desktop app in headless mode | the desktop app, minimised to the tray, with "run the LLM server on login" checked | a workstation that already has a desktop session | **llmster** arrived with LM Studio 0.4.0. On a server with no display it is the only sensible choice: the documentation scopes the desktop app's headless mode to machines with a graphical user interface. The daemon and the desktop app share the `lms` CLI, so everything below works the same on both. ## The provisioning sequence 1. **Install.** `curl -fsSL https://lmstudio.ai/install.sh | bash`, then `lms --help` to verify. The documented systemd unit calls the binary as `~/.lmstudio/bin/lms` of the service user, so use the full path in units. 2. **Start the daemon.** `lms daemon up` starts llmster and prints its PID, or reports the status if it is already running; `lms daemon status --json` returns `{"status": "running", ...}` for a health check. `lms daemon down` stops it; it does not stop a desktop app. 3. **Download.** `lms get <model> --yes`. Without `--yes`, `lms get` may prompt you to pick among search results or download options; with it, the first match and the option preselected for this hardware are used. Pin the option with `<model>@<quant>` when it matters. 4. **Pre-flight.** `lms load --estimate-only <model> --context-length 16384 --gpu max` prints estimated GPU and total memory and a verdict against the resource-guardrail settings, without loading. It honours the other flags and accounts for flash attention and vision models (it arrived in LM Studio 0.3.27). 5. **Load.** `lms load <model> --yes --gpu max --context-length 16384 --identifier chat-main`. `--yes` avoids an interactive pick when several models match; the explicit flags stop the box depending on saved per-model defaults; the identifier gives clients a stable name. 6. **Serve.** `lms server start`. Without `--port` it reuses the port it last ran on, falling back to 1234; without `--bind` (or `LMS_SERVER_HOST`) it listens on 127.0.0.1 only. ## Two traps for scripts - **The CLI writes its messages to stderr.** In the pinned `lms` source the logger sends informational output to stderr, and the estimate verdict ("may be loaded" or "will fail to load") is printed that way. A script must redirect `2>&1` before it greps the verdict. - **The verdict is not an exit status.** The same source returns normally after printing either verdict, so `set -e` alone will not stop the script on a bad estimate; test the text. ## Reboots: the documented systemd unit LM Studio's Linux guide uses a unit with `Type=oneshot` and `RemainAfterExit=yes`, `User=` and `HOME=` for the service account, two `ExecStartPre` lines (`lms daemon up`, then `lms load <model> --yes`), `ExecStart` running `lms server start` and `ExecStop` running `lms daemon down`. Enable it with `systemctl enable` and check it with `systemctl status` and `curl http://localhost:1234/v1/models`. The guide also offers an alternative: load nothing at boot and let the server load models on demand, which trades first-request latency for memory (the on-demand loading rules belong to the server's own configuration). ## What the box looks like afterwards - One loaded instance named `chat-main`, with **no idle TTL**, because `lms load` sets none unless you pass `--ttl`: right for a dedicated server, wasteful for a shared one. - An HTTP server reachable on localhost only. Exposing it to other machines with `--bind 0.0.0.0` is a separate decision that should come with authentication turned on, which LM Studio leaves off by default. - Updates are explicit: `lms daemon down`, `lms daemon update`, `lms daemon up`. ## What interviewers listen for - Naming llmster and `lms daemon up` rather than "run the app with no window". - Knowing every place `lms` would prompt, and passing `--yes` there. - Treating `--estimate-only` as a pre-flight and knowing its output goes to stderr. - Remembering that a reboot replays the unit, so the load step must be safe to repeat.

  • Why does the documented unit use Type=oneshot with RemainAfterExit=yes?
    The `lms` commands exit once the daemon has started, loaded the model and started the server; llmster keeps running on its own. Oneshot lets systemd run them in order and `RemainAfterExit=yes` keeps the unit marked active, so `ExecStop` (`lms daemon down`) still runs on stop.
  • A colleague's script runs lms load without --yes under systemd and the boot hangs on that step. Why?
    When several downloaded models match the key, `lms load` opens an interactive picker and waits for input that a service never gives. `--yes` auto-approves: it loads on the preferred device or takes the first match. Pinning the exact key avoids the ambiguity altogether.
  • When would you skip the load step and rely on on-demand loading instead?
    When the box serves several models that are each used rarely: loading at boot pins memory for all of them, while on-demand loading pays the load time on the first request and lets idle models be unloaded. A single latency-sensitive model is better pinned with an explicit `lms load`.

  • Headless LM Studio means running the desktop app with no window
  • lms daemon down also stops a desktop app instance
  • --estimate-only exits non-zero when the guardrails would refuse
  • lms server start always uses port 1234
  • The server listens on all interfaces once started headless
  • lms load at boot sets the 60-minute idle TTL

Assumes LM Studio 0.4.0 or newer (llmster and lms daemon arrived in 0.4.0; lms load --estimate-only in 0.3.27); docs fetched 2026-10-04, when 0.4.25 was current.

open as a page

With LM Studio's lms CLI, how do you download a model, tell disk from memory, and import a GGUF you already have?

level: juniorimportance: should knowfreq 8%

basics

~20 s

lms get downloads into LM Studio's models directory and lms ls lists what is on disk; lms load and lms ps load and list what is in memory; lms import adopts an existing file, moving it unless you pass --copy.

open as a page

An app on LM Studio's server gets replies ignoring its system prompt — how does lms log stream show what the model received?

level: middleimportance: should knowfreq 5%

basics

~20 s

lms log stream prints, for each prediction made while it is attached, the model identifier and the exact formatted input string, then the output, so you can see whether the system text survived the request and the chat template.

open as a page

A deploy script runs lms load your-model on every release; why does lms ps list several copies a week later, and what fixes it?

level: middleimportance: should knowfreq 7%

basics

~20 s

Every lms load creates a new instance even when the model is already loaded, and lms-loaded models have no idle TTL, so copies pile up. Unload first, give the load a fixed --identifier so a repeat errors out, or add --ttl.

open as a page

In lmstudio-python, why can lms.llm("your-model", config={"contextLength": 16384}) return a model running at a smaller context, and how do you guarantee yours?

level: middleimportance: nice to knowfreq 3%

basics

~20 s

lms.llm(key) gets an already-loaded instance of that model if one exists and only loads when none does, so its config and ttl are ignored for an existing instance. Use load_new_instance() with the config, or unload first, then check get_load_config().

open as a page

In lmstudio-python, what does model.act() handle that a hand-rolled tool loop over LM Studio's OpenAI-compatible endpoint makes you write, and what stays your job?

level: seniorimportance: nice to knowfreq 6%

basics

~20 s

model.act() turns typed, documented Python functions into tool definitions, runs prediction rounds, executes requested tools in your process and feeds results back until the model stops calling tools; round limits, parallelism, error policy and side-effect safety stay yours.

open as a page