skip to content

LM Studio

LM Studio pairs a desktop app with the llmster daemon, the lms CLI and a server speaking OpenAI, Anthropic and native routes over llama.cpp or MLX. Interviewers ask what the GUI decides for you.

part ofLocal LLM runtimesread it →
on this pageshow

explore

questions

17

Wiring a coding-assistant extension to LM Studio's local server, what base URL, API key and model identifier does it need?

level: juniorimportance: must knowfreq 16%

answer

  1. one port, several route families
  2. the /v1 suffix matters
  3. key unchecked until auth is on
  4. the id the models route lists
  5. first call loads the model

basics

~10 s

An OpenAI-style client uses http://localhost:1234/v1 and an Anthropic-style client http://localhost:1234. Any placeholder key works while Require Authentication is off, and the model is an identifier that GET /v1/models lists.

solid answer

~40 s

Start the server with the **Start server** switch in LM Studio's Developer tab; it listens on port `1234` by default, and the port is a Server Settings value you can change. An OpenAI-style client takes `http://localhost:1234/v1` as its base URL; an Anthropic-style client takes `http://localhost:1234`, because its SDK appends `/v1/messages` itself. LM Studio does not require authentication by default, so the key is not checked and the docs' examples pass a placeholder such as `lm-studio`; once **Require Authentication** is on (LM Studio 0.4.0 or newer) it must be a real API token. The `model` value is an identifier from `GET /v1/models`. With Just in Time Model Loading on, the default, that list holds every downloaded model and the first request for one loads it, so that call is slow.

code

python · 15 lines
python
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:1234/v1",
    api_key="lm-studio",  # any value while Require Authentication is off
)

# The identifiers the server will accept as `model`
print([m.id for m in client.models.list().data])

reply = client.chat.completions.create(
    model="your-model",  # one of the ids printed above
    messages=[{"role": "user", "content": "Say hello."}],
)
print(reply.choices[0].message.content)

go deeper

for a junior

Recall port 1234, the /v1 base URL for OpenAI-style clients, that the key is unchecked by default, and that the model id comes from GET /v1/models.

for a middle

Explain why OpenAI and Anthropic clients need different base URLs, and how JIT loading changes both what /v1/models lists and how long the first call takes.

for a senior

Show you know which defaults stop being safe: a placeholder key only works while authentication is off, and the localhost bind is what keeps an unauthenticated server private.

for a principal

Weigh standardising every tool on one compatible route family against using LM Studio's native API for its extras, given that each client SDK fixes the route it calls.

## What the extension is talking to LM Studio's **local server** is the HTTP API the desktop app (or its headless daemon) exposes so that other programs can use the models you downloaded. You start it from the **Developer** tab by toggling the **Start server** switch; the LM Studio CLI can start it too. Once it is up it answers on **port 1234** by default, bound to `127.0.0.1`, so only programs on the same machine can reach it. The port is the **Server Port** value under Server Settings, which matters if something else on the machine already owns 1234. One port carries several **route families**, and a client picks the family its SDK speaks: - OpenAI-style routes under `/v1`: `/v1/models`, `/v1/chat/completions`, `/v1/responses`, `/v1/embeddings` and `/v1/completions`. - An Anthropic-style route, `/v1/messages`. - LM Studio's own REST API under `/api/v1`, which also loads, unloads and downloads models. A coding-assistant extension almost always ships with an OpenAI-compatible or Anthropic-compatible provider setting, so the job is filling three fields correctly. ## The three values a client needs | Field | OpenAI-style client | Anthropic-style client | When it changes | |---|---|---|---| | Base URL | `http://localhost:1234/v1` | `http://localhost:1234` | You change the port, or reach the server from another machine | | API key | any placeholder | any placeholder | **Require Authentication** is switched on: a real token | | Model | an id from `GET /v1/models` | the same id | You download or load a different model | The base URL differs because each SDK appends its own path. The OpenAI SDK adds `/chat/completions` to whatever base you give it, so the base must already end in `/v1`. The Anthropic SDK adds `/v1/messages`, so its base stops at the port; giving it `/v1` produces a doubled path that the server does not serve. ## Where the model identifier comes from The `model` field is not a file name. It is the identifier LM Studio assigns, the value the `/v1/models` route returns (for example a `publisher/model` key). What that route returns depends on **Just in Time (JIT) loading**: 1. With JIT loading **on** (the default), `GET /v1/models` lists every downloaded model, loaded or not. 2. The first inference request that names an unloaded model makes the server load it, then answer. That first call waits for the load; later calls are fast. 3. With JIT loading **off**, `GET /v1/models` lists only models already in memory, and a request for anything else fails until you load it yourself. So an extension that offers a model picker filled from `/v1/models` shows your whole library by default, and picking an entry is enough to load it. ## When the key starts to matter By default **LM Studio does not require authentication** for API requests, so the key field is decoration. The OpenAI SDK still wants a value, which is why the docs pass a placeholder. That changes when someone switches on **Require Authentication** in Server Settings, available from LM Studio 0.4.0: from then on API clients must present a valid API token in the `Authorization` header, which is exactly where the OpenAI SDK puts its `api_key`. The Anthropic-style route also accepts the token in `x-api-key`. Tokens are created under **Manage Tokens**; this matters most once the server is reachable from other machines. ## First-day failures and their causes - **Connection refused** — the server switch is off, or the port is no longer 1234. - **404 on every call** — an OpenAI client was given a base URL without `/v1`, or an Anthropic client one with it. - **A long pause, then an answer** — JIT loading is loading the model on the first request; nothing is broken. - **The model list shows one entry although ten are downloaded** — JIT loading is off, so only loaded models are listed. - **Rejected requests after a settings change** — authentication was switched on and the placeholder key is no longer accepted. ## Checking the setup before blaming the extension Two requests from a terminal settle most doubts: 1. `GET http://localhost:1234/v1/models` — if it answers, the server is up on that port, and the ids it returns are the only values `model` may take. 2. A one-line chat request naming one of those ids — slow once and fast afterwards means JIT loading is working as designed. If the first fails, fix the server switch or the port. If the second fails with an id the server listed, look at the model itself, for example whether it can be loaded on this machine, rather than at the extension's settings. The request and response bodies themselves follow the hosted APIs' contracts; what is specific here is the port, the path, the key policy and the identifier.

  • Why does the first request of the morning take far longer than the rest?
    With JIT loading on, a request for a model that is not in memory makes LM Studio load it before answering. Models loaded that way are unloaded again after 60 idle minutes by default, so the first call after a quiet spell pays the load and later calls do not.
  • The extension's model picker shows only one model although ten are downloaded. What is going on?
    Just in Time Model Loading is switched off. In that mode `GET /v1/models` returns only models already loaded into memory, and requests for any other model fail until you load it. Turn JIT loading back on, or load the models the extension needs.

  • LM Studio's server rejects requests without a valid API key by default.
  • An OpenAI client's base URL is http://localhost:1234 with no /v1.
  • The model field must be the GGUF file name on disk.
  • Every model has to be loaded by hand before an API request can use it.
  • An Anthropic client should use http://localhost:1234/v1 as its base URL.
open as a page

A 30B model downloaded from LM Studio's Discover tab refuses to load on a 32 GB MacBook — what decides that, and what do you change?

level: seniorimportance: must knowfreq 16%

basics

~20 s

Before loading, LM Studio estimates the memory the model and its context need and checks it against your resource guardrails setting; a failing estimate is refused. Lower the context length, use flash attention on GGUF, or pick a smaller download option.

open as a page

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%

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.

open as a page

In LM Studio's Discover tab, how do you get one specific Hugging Face model build, and where does the download land?

level: juniorimportance: should knowfreq 14%

basics

~20 s

Search Discover by keyword, by a user/model string or by pasting the full Hugging Face URL, then pick one download option. The file lands in LM Studio's models directory under publisher and model folders; My Models lets you move that directory.

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

With LM Studio's JIT loading on, when does a model the server loaded on demand get unloaded, and how do you change that?

level: middleimportance: should knowfreq 9%

basics

~20 s

A JIT-loaded model unloads after sitting idle for its TTL, 60 minutes by default. Change the app-wide default for JIT loads in the server settings, or send a ttl field, in seconds, with the request that loads it.

open as a page

On an Apple Silicon Mac, LM Studio offers a GGUF and an MLX build of one model — what differs, and which do you choose?

level: middleimportance: should knowfreq 9%

basics

~20 s

A GGUF build runs on LM Studio's llama.cpp engine on Mac, Windows and Linux; an MLX build runs on Apple's MLX engine, on Apple Silicon only. Pick MLX for a Mac-only setup, GGUF when other machines must match.

open as a page

In LM Studio, where do per-model default load settings live, what do they fix, and which loads inherit them?

level: middleimportance: should knowfreq 8%

basics

~20 s

Per-model defaults are set from the gear icon on a model in My Models: GPU offload, context length, flash attention and more. Every later load of that model in LM Studio, lms load included, starts from them.

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

A coding extension on LM Studio's server alternates a chat model, an autocomplete model and an embedding model, and every switch waits for a reload — why, and what do you change?

level: seniorimportance: should knowfreq 7%

basics

~20 s

Auto-Evict, on by default, keeps at most one JIT-loaded model, so each request for a different model unloads the previous one first. Turn Auto-Evict off if memory holds all three, or load them explicitly, which Auto-Evict leaves alone.

open as a page

Before switching on LM Studio's Serve on Local Network so a second office machine can use the server, what do you configure and why?

level: seniorimportance: should knowfreq 8%

basics

~20 s

Serve on Local Network exposes a server that by default needs no authentication, so first switch on Require Authentication (LM Studio 0.4.0+), issue each client its own API token with only the permissions it needs, and leave Enable CORS off.

open as a page

How do you make LM Studio's /v1/chat/completions return JSON matching a schema, and what should the client still check?

level: middleimportance: nice to knowfreq 4%

basics

~20 s

Send response_format with type json_schema and the schema under json_schema.schema; LM Studio constrains GGUF models with llama.cpp grammars and MLX models with Outlines. The JSON still arrives as a string in choices[0].message.content, so parse and validate it.

open as a page

LM Studio's server offers /v1/chat/completions, /v1/responses, /v1/messages and the native /api/v1/chat — what decides which one a client should call?

level: middleimportance: nice to knowfreq 6%

basics

~20 s

Call the route the client's SDK already speaks: /v1/chat/completions or /v1/responses for OpenAI SDKs, /v1/messages for Anthropic ones. Use native /api/v1/chat for LM Studio-only features such as per-request context length, but it takes no custom tools.

open as a page

In LM Studio, how are the inference engines shipped and updated separately from the app, and when does that bite?

level: middleimportance: nice to knowfreq 5%

basics

~20 s

LM Studio packages its engines (llama.cpp, MLX) as separate runtimes, downloadable and hot-swappable without an app update since LM Studio 0.3.0. One runtime is selected per model format, and an outdated or CPU-only runtime explains missing features or GPU use.

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