LM Studio: install, models, headless server and API setup
What LM Studio is, how to install it, which models fit your hardware, and how to run llmster headless on Linux and serve Claude Code, Codex and OpenCode.
LM Studio is a free desktop app for Mac (Apple silicon), Windows and Linux that downloads open models from Hugging Face (GGUF, and MLX on Macs) and runs them on your own hardware, with a chat window and a local API server on port 1234 that speaks OpenAI’s, Anthropic’s and its own REST format. On a server without a screen you install its headless daemon, llmster, with curl -fsSL https://lmstudio.ai/install.sh | bash, and drive it with the lms command: lms daemon up, lms get, lms load, lms server start. Claude Code, Codex and OpenCode all connect to it. It is free for work use but not open source, and its API needs no token unless you turn one on. The current version, as of December 2026, is 0.4.29.
The home page at lmstudio.ai now leads with Bionic, a separate agent app from the same company. Everything below is about LM Studio itself and llmster, both on the download page. If you are choosing between LM Studio and Ollama, the comparison is in Ollama vs LM Studio; this page is about running LM Studio itself.
Three pieces with one name
LM Studio’s own docs separate them like this:
| Piece | What it is | Where you use it |
|---|---|---|
LM Studio | The desktop app: model search, chat, document chat, MCP servers, load settings, the server switch | A Mac, a Windows PC, a Linux desktop |
llmster | “LM Studio’s headless daemon”, the app’s core with no window | A Linux server, a GPU box with no display, CI |
lms | The command line (MIT-licensed) that controls either one | Any terminal, including over SSH |
lms comes with the app and with llmster; if a shell cannot find it after installing the app, its repository gives npx lmstudio install-cli to put it on your PATH.
Installing it, and what hardware it wants
The desktop app is a download for each system: an Apple-silicon build for macOS, an installer for Windows, and an AppImage or a .deb for x64 Linux. The system requirements, as of December 2026:
| System | Requirements |
|---|---|
macOS | Apple silicon, macOS 14.0 or newer, 16GB of memory recommended (8GB Macs can run small models with modest context); Intel Macs are not supported |
Windows | x64 with AVX2, or ARM (Snapdragon X Elite); 16GB of RAM and 4GB of dedicated VRAM recommended |
Linux | Ubuntu 20.04 or newer required, versions after 22 “not well tested”; x64 builds ship with AVX2 support by default |
On Linux ARM64 the maker’s pages disagree: the requirements page lists it, while the app’s overview names x64 Linux only and the download page offers only x64 builds.
llmster installs from a terminal for your own user, on Linux and macOS:
curl -fsSL https://lmstudio.ai/install.sh | bashCopiedand on Windows, in PowerShell:
irm https://lmstudio.ai/install.ps1 | iexCopiedBoth pipe a script from LM Studio’s site straight into a shell, so read it first if your policy asks for that. Open a new shell afterwards and check with lms --help; the binary lives in ~/.lmstudio/bin.
Getting a model and checking it fits
Models come from Hugging Face. In the app that is the Model Search page; on a server it is lms get, which shows staff picks when given no name and otherwise searches, offering only formats your installed engines can run:
lms get
lms get openai/gpt-oss-20b
lms get llama-3.1-8b@q4_k_mCopiedThe @q4_k_m suffix picks a quantisation; --gguf or --mlx limits the search to one format. GGUF models run everywhere through llama.cpp, and MLX models only on Apple silicon. Which model runs well is a question of memory: the weights and the context window both have to fit, ideally all on the GPU. Before loading anything big, ask for an estimate:
lms load openai/gpt-oss-20b --context-length 32768 --estimate-onlyCopiedThat prints a memory estimate and exits. lms ls lists what is downloaded, lms ps what is loaded, and lms runtime ls, get and update manage the inference engines, which LM Studio downloads separately from the app. By default lms load decides itself how much of the model goes on the GPU; --gpu max, off or a fraction such as 0.5 overrides it.
The local server and its three APIs
Start it with lms server start (or from the app). It listens on 127.0.0.1, port 1234 the first time and the last port used after that, so pass --port 1234 when other tools expect it. One port serves three APIs:
| API | Paths | Who uses it |
|---|---|---|
/v1/models, /v1/chat/completions, /v1/responses, /v1/embeddings, /v1/completions | Codex (Responses), OpenAI SDKs, most tools | |
/v1/messages | Claude Code | |
Native REST (since 0.4.0) | /api/v1/chat, /api/v1/models, and load, unload and download under /api/v1/models/ | OpenCode’s model discovery, scripts that manage models |
Just-in-time loading is on by default: a request naming a downloaded model that is not in memory loads it, /v1/models lists everything downloaded rather than only what is loaded, and a model loaded that way is unloaded after 60 idle minutes, with only one such model kept in memory at a time. A model you load yourself with lms load has no idle timeout unless you add --ttl in seconds. To see exactly what an agent sends and gets back, run lms log stream in a second terminal.
Running it headless on a Linux server
Over SSH, the whole sequence is:
lms daemon up
lms get openai/gpt-oss-20b
lms load openai/gpt-oss-20b --context-length 32768
lms server start --port 1234
curl http://localhost:1234/v1/modelsCopiedThose commands start nothing again after a reboot; to have it come up at boot, LM Studio’s headless guide gives a systemd unit. Save it as /etc/systemd/system/lmstudio.service with your user name in place of YOUR_USERNAME (writing the file replaces any unit of that name):
[Unit]
Description=LM Studio Server
[Service]
Type=oneshot
RemainAfterExit=yes
User=YOUR_USERNAME
Environment="HOME=/home/YOUR_USERNAME"
ExecStartPre=/home/YOUR_USERNAME/.lmstudio/bin/lms daemon up
ExecStartPre=/home/YOUR_USERNAME/.lmstudio/bin/lms load openai/gpt-oss-20b --yes
ExecStart=/home/YOUR_USERNAME/.lmstudio/bin/lms server start
ExecStop=/home/YOUR_USERNAME/.lmstudio/bin/lms daemon down
[Install]
WantedBy=multi-user.targetCopiedThen enable it and check it:
sudo systemctl daemon-reload
sudo systemctl enable --now lmstudio.service
systemctl status lmstudioCopiedThree things about that unit. The load line has no context length, so add --context-length with the size your agent needs (next section). An ExecStartPre line that exits with an error stops systemd from running the lines after it, so if that load fails (a model deleted since, say), the server does not start; LM Studio’s guide offers leaving the model out and relying on just-in-time loading instead. And the server comes up on the last port used, which is 1234 if that is what you started it on by hand; add --port 1234 to the ExecStart line to pin it.
To update llmster, stop it, update, and start it again: lms daemon down, lms daemon update (add --beta for the beta channel), then lms daemon up, or sudo systemctl restart lmstudio if the unit runs it.
Context length: set it, do not trust the default
A coding agent sends long instructions and tool definitions before it sends your request. LM Studio’s own pages for Claude Code and Codex ask for a model loaded with more than about 25k tokens of context, and LM Studio’s docs state no default number anywhere, so treat the context as something you choose. It is fixed when the model loads, from one of three places:
--context-lengthonlms load, as in the commands above;- the model’s saved default load settings in the app, which also apply to
lms load; - a request to the native
/api/v1/chat, which can name a context length. The OpenAI- and Anthropic-compatible endpoints cannot, so agents using them get whatever the model was loaded with.
LM Studio’s docs do not say which length a just-in-time load triggered by Claude Code or Codex gets, and on a machine with only llmster there is no app window in which to save a default, so on a server, preload the model with an explicit length and the question goes away. Each extra token of context costs memory, so run the --estimate-only check again at the length you choose.
Connecting coding agents
Claude Code
Claude Code talks to /v1/messages. LM Studio’s page gives these variables, with any value for the token while authentication is off:
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model openai/gpt-oss-20bCopiedThe Ollama version of the same setup, with its own caveats, is in Claude Code with Ollama.
Codex
Codex has LM Studio built in as a provider. codex --oss asks which local server to use unless oss_provider = "lmstudio" is set in ~/.codex/config.toml, and with no model named it downloads and uses openai/gpt-oss-20b; another model goes after -m:
codex --oss -m ibm/granite-4-microCopiedIt uses the Responses endpoint. More on picking Codex’s model in choosing Codex’s model.
OpenCode
OpenCode’s providers page has an lmstudio provider whose default address is http://127.0.0.1:1234/v1, and it finds your models through the native /api/v1/models. For a server on another machine, set the provider’s baseURL in opencode.json to that machine’s address, or keep the default and tunnel the port (below). The Ollama route for the same agent is OpenCode with Ollama.
API tokens, and who can reach the server
By default LM Studio’s API asks for no token, so anything that can reach the port can use your models. Since 0.4.0 it can require one: turn on Require Authentication under Server Settings on the app’s Developer page, then Manage Tokens, Create Token, give it a name and permissions, and copy it, since it is shown once. Clients send it as Authorization: Bearer; the Anthropic endpoint also accepts x-api-key.
That switch lives in the app. LM Studio’s docs describe no lms command or setting file for it, so on a server with only llmster, plan on having no token and control who can reach the port instead. The app’s Server Settings also hold two MCP switches, letting a request bring its own remote MCP servers or call those in your mcp.json. The docs call the second risky where those servers can reach files or private data, and it works only with authentication on.
Where you do have a token, keep it out of shell history. Run the line below, paste the token, and press Enter (nothing is shown):
read -rs LM_API_TOKENCopiedThen pass it to Claude Code:
export ANTHROPIC_AUTH_TOKEN="$LM_API_TOKEN"CopiedCodex’s LM Studio page gives no token setup, and the built-in lmstudio provider cannot be redefined. Reading Codex’s config reference alongside it, a custom provider in ~/.codex/config.toml that reads the same variable should do it. That is a reading of the two docs together, not a setup either maker publishes:
model_provider = "lmstudio-token"
model = "openai/gpt-oss-20b"
[model_providers.lmstudio-token]
name = "LM Studio with a token"
base_url = "http://localhost:1234/v1"
env_key = "LM_API_TOKEN"
wire_api = "responses"CopiedReaching it from another machine. lms server start --bind 0.0.0.0 (the app’s “Serve on Local Network”) listens on every interface, which on a server with a public address means the internet, with no token in the headless case; LM Studio’s own docs say to enable authentication for any bind other than 127.0.0.1. The private way is to leave it on loopback and forward the port over SSH from the machine where the agent runs:
ssh -N -L 1234:127.0.0.1:1234 you@gpu-boxCopiedThe agent then uses http://localhost:1234 as if the model were local; more in opening a localhost app on a remote server. A private network such as Tailscale, with the server bound to that interface’s address only, does the same without a tunnel per session. LM Studio also has its own LM Link, end-to-end encrypted links between your own devices built with Tailscale, which its Claude Code and Codex pages suggest for running the agent on a laptop and the model on a bigger machine.
Licence and work use
LM Studio has been free at work since July 8, 2025, with “no need to fill a form or contact us”; an Enterprise plan exists for single sign-on and model gating. It is closed source. Its terms (version of August 23, 2026) license it “solely for Your personal and / or internal business purposes” and rule out offering it to others “as an application service provider, or a software-as-a-service”. Read plainly, a team serving its own agents falls within that and selling inference from it to others does not. The models carry their own licences, which the terms leave between you and each model’s publisher. If you need open source end to end, Ollama is MIT-licensed; running Ollama as a server covers the same headless setup there.
Versions
As of December 2026 the download page offers LM Studio 0.4.29 for all three systems. Its release notes carry no date; they add per-model engine and version overrides in the load settings and move Model Search to a full page. Tokens on the API and the native /api/v1 REST endpoints both arrived in 0.4.0, so a guide written for 0.3 will not mention them. Whether a local machine or a rented GPU is the better place for the model is weighed in a local AI box against the cloud.