New Tool Radar

Local AI

Load and Unload a Model in LM Studio from the Command Line with lms

Use the lms command line to list, load, and unload models in LM Studio, and start the local server headlessly.

Schematic with three steps: List downloaded models; Load a model with a lifetime; Start the server and unload when done.

LM Studio ships a command-line tool, lms, for headless use. It lists downloaded models, loads one with a lifetime and an identifier, and starts the local API server, all without opening the app window.

What you need

  • LM Studio installed with the command-line tool available
  • At least one model downloaded in LM Studio
  • A terminal on the same machine

Step 1: List downloaded models

Run lms get to see the models available on disk, or lms ls for a short list. Each entry shows the model identifier you pass to the load command.

Step 2: Load a model with a lifetime

Run lms load <model-id> –ttl 3600 –identifier my-model. The –ttl flag unloads the model after 3600 seconds idle, and –identifier gives it a stable name for API calls. Check it with lms ps.

Step 3: Start the server and unload when done

Run lms server start –port 1234 to serve the loaded model on the OpenAI-compatible API. When finished, run lms unload my-model to free the memory.

Worked example: load a model for one hour

The table below is a synthetic example. The lms commands and flags come from the cited headless guides; the model identifier is illustrative.

Step Command Expected result
List lms get Downloaded models listed
Load lms load <model> –ttl 3600 Model loaded, shown in lms ps
Serve lms server start –port 1234 API answers on port 1234

Expected result (UNTESTED). lms ps shows the loaded model, the server answers on port 1234, and the model unloads after the TTL or with lms unload. This check was not run live; the commands come from the cited headless guides.

Limits

  • lms needs the LM Studio daemon running; use lms daemon up if it is not.
  • The –ttl lifetime counts idle time, not total time.
  • Model identifiers must match the downloaded model exactly.
  • The server needs an API key only if one is set in the app; the key cannot be set from lms.

Sources

See all