LM Studio is best known for its desktop app, but it also has a powerful command-line tool called lms. With it you can download models, load them onto your GPU with exact settings, start the local API server, stream logs and chat, all from a terminal or a script.
Since LM Studio 0.4 there’s also llmster, a headless version of LM Studio’s engine with no GUI, which makes LM Studio usable on servers and always-on machines.
This guide covers how to get lms, every everyday command with its useful flags, running LM Studio headless with llmster, automating it in scripts, and fixing common problems. It follows the official LM Studio CLI docs as of November 2026 (LM Studio 0.4.28).
- Get lms: it ships with LM Studio; run the app once, then
lms --help. If missing:npx lmstudio install-cli. - Download:
lms get llama-3.1-8b@q4_k_m. - Load:
lms load <model> --gpu max --context-length 8192. - Server:
lms server start --port 1234. - Headless: install llmster, then
lms daemon up. - Check:
lms ls(downloaded),lms ps(loaded).
How to Get the lms CLI
- Install LM Studio from lmstudio.ai and open it at least once.
- Open a new terminal (Terminal, PowerShell or Command Prompt).
- Run
lms --help. If you see the command list, you’re done. - If the command isn’t found, run
npx lmstudio install-clito addlmsto your PATH, then open a fresh terminal.
lms talks to a running LM Studio app or llmster daemon. If neither is running, many commands will start or ask for the service first.
lms Command Cheat Sheet
| Command | What it does |
|---|---|
lms ls |
List downloaded models (--json for scripts) |
lms ps |
List models currently loaded in memory |
lms get <model> |
Search and download a model |
lms load <model> |
Load a model with chosen GPU and context settings |
lms unload <id> / --all |
Free memory by unloading models |
lms server start / stop / status |
Control the local API server |
lms chat [model] |
Chat in the terminal |
lms log stream |
Watch prompts, responses and stats live |
lms import <file.gguf> |
Add a local model file to LM Studio |
lms status |
Show what LM Studio is doing |
lms runtime |
Manage inference runtimes (llama.cpp, MLX) |
lms daemon up / down / status |
Control the headless llmster daemon |
Download Models With lms get
- Search and download by name, optionally with a quantization:
lms get llama-3.1-8b@q4_k_m - Pick a format if you want:
--gguffor llama.cpp or--mlxfor Apple Silicon. - See all download options with
-a(--always-show-download-options). - Limit search results with
-n 5. - Confirm it’s there with
lms ls.
Q4_K_M is a good default balance of size and quality for most PCs. More on picking files in how to download models from Hugging Face.
Load and Unload Models
lms load qwen3-8b --gpu max --context-length 8192 --identifier "chat"
| Flag | Meaning |
|---|---|
--gpu max |
Offload as much as possible to the GPU (or a value 0-1, or off) |
--context-length 8192 |
Context window in tokens |
--identifier "chat" |
A friendly name the API uses for this loaded model |
--ttl 3600 |
Unload automatically after this many idle seconds |
--estimate-only |
Show how much memory the load would use, without loading |
-y |
Skip confirmation prompts |
Unload with lms unload chat or everything with lms unload --all. Use --estimate-only first on big models to avoid running out of memory.
Start the Local API Server
- Start it:
lms server start --port 1234 - Allow browser apps with
--corsif a web app needs to call it. - Expose it on your network with
--bind 0.0.0.0(default is 127.0.0.1), or setLMS_SERVER_HOST. - Check it with
lms server status. - Stop it with
lms server stop.
If you leave out --port, LM Studio reuses the last port you set. The server speaks the OpenAI API format, so any OpenAI client can use http://localhost:1234/v1. Full API examples are in our LM Studio API guide.
Chat and Stream Logs
- Interactive chat:
lms chat qwen3-8b. - One-off prompt:
lms chat qwen3-8b -p "Explain RAG in 3 lines". - System prompt: add
-s "You are a helpful tutor". - Speed stats: add
--statsto see tokens per second. - Pipe text in:
cat notes.txt | lms chat qwen3-8b -p "Summarise this". - Watch the server:
lms log stream -s server, or--filter input,outputto see prompts and replies.
Import GGUF Files
lms import ./my-model-Q4_K_M.gguf --user-repo myname/my-model
| Flag | Effect |
|---|---|
--copy |
Copy the file into LM Studio’s models folder |
-L |
Create a hard link instead of copying |
-l |
Create a symbolic link |
--dry-run |
Show what would happen |
Made your own GGUF? See how to convert a model to GGUF, then import it.
Run LM Studio Headless With llmster
llmster is LM Studio’s core engine without the desktop interface, introduced with LM Studio 0.4.0. It’s ideal for a home server, a Linux box or a cloud GPU.
- Install llmster on Linux or macOS:
curl -fsSL https://lmstudio.ai/install.sh | bashOn Windows PowerShell:
irm https://lmstudio.ai/install.ps1 | iex - Start the daemon:
lms daemon up. - Download and load a model with
lms getandlms load. - Start the server:
lms server start --bind 0.0.0.0. - Manage it with
lms daemon status,lms daemon updateandlms daemon down.
On Linux, the docs show how to start llmster at login with systemd. Only bind to 0.0.0.0 on a network you trust.
Automate LM Studio in Scripts
#!/bin/bash
lms daemon up
lms load qwen3-8b --gpu max --context-length 8192 --identifier work -y
lms server start --port 1234
# ... run your app or tests against http://localhost:1234/v1 ...
lms unload --all
lms server stop
- Use
--jsononlms lsandlms psto parse output in scripts. - Use
--ttlso idle models free memory automatically. - Pair it with agents and MCP: see our LM Studio MCP and agent mode guide.
Tips for Using lms Day to Day
- Give loaded models identifiers. Apps then call a stable name like “work” even if you swap the underlying model.
- Estimate before loading.
--estimate-onlytells you whether a 30B model will fit before you try. - Keep one terminal on logs.
lms log streamshows exactly what your app sends, which makes debugging prompts much easier. - Unload when gaming.
lms unload --allfrees VRAM in one command.
Example: A Morning Startup Script
Here’s a practical way to put everything together. This small script starts the server, loads your usual model under a stable name and confirms it’s ready, so your editor, agents or scripts can connect straight away.
lms server start
lms load qwen3-8b --identifier work --context-length 16384
lms ps
curl http://localhost:1234/v1/models
- Save the lines above as
start-ai.sh(orstart-ai.baton Windows). - Replace
qwen3-8bwith a model key fromlms ls. - Run it once to check the model loads and the curl call lists it.
- Add it to your login items or a scheduled task if you want it every boot.
At night, lms unload --all and lms server stop give the GPU back for games or rendering.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
lms: command not found |
CLI not on PATH | Open LM Studio once, then run npx lmstudio install-cli and open a new terminal |
| Can’t connect to LM Studio | App or daemon not running | Open LM Studio or run lms daemon up |
| Model fails to load | Not enough memory | Lower --context-length, use --gpu 0.5, or a smaller quant |
| Other devices can’t reach the server | Bound to 127.0.0.1 | Use --bind 0.0.0.0 and allow the port in your firewall |
| Web app blocked by CORS | CORS off | Start the server with --cors |
| Server started on an unexpected port | Reused the last port | Pass --port explicitly |
| Imported model not listed | Wrong folder or format | Re-run lms import with --user-repo; check lms ls |
More loading fixes: LM Studio not loading models. Comparing tools? See LM Studio vs Ollama.
FAQ
What is lms in LM Studio?
It’s LM Studio’s command-line tool for downloading, loading and serving models from a terminal.
How do I install the LM Studio CLI?
It comes with LM Studio. Run the app once, then use lms in a new terminal. If it’s missing, run npx lmstudio install-cli.
Can LM Studio run without the GUI?
Yes. Install llmster, LM Studio’s headless daemon, and control it with lms daemon up and the other lms commands.
How do I start the LM Studio server from the command line?
Run lms server start, optionally with –port, –cors and –bind 0.0.0.0.
How do I see which models are loaded?
Run lms ps. Use lms ls to see all downloaded models.
Can I set GPU offload with lms?
Yes. Use lms load with –gpu max, a value from 0 to 1, or off.
Is the LM Studio CLI free?
Yes. It’s part of the free LM Studio app.




