# LM Studio tutorial: run local models in a desktop app

> LM Studio is a desktop app for running open AI models on your own computer, with a built-in model search, a chat window and a local server that speaks the OpenAI API. This LM Studio tutorial downloads a model from the built-in search, loads it and chats with it, starts the server for your code and covers the `lms` command line.

Mindket editors · Published 2026-11-05 · Updated 2026-11-05 · https://mindket.com/learn/local-ai/lm-studio-tutorial

## In short

- Pick a download size your machine can hold before the progress bar starts.
- Ask questions about a PDF without the file leaving your computer.
- Reuse code written for OpenAI against a model sitting on your own desk.
- Load and unload models from a terminal or a script.

## Before you start

LM Studio wraps the same kind of engine as Ollama in a desktop app. On every system it runs GGUF files through llama.cpp. GGUF is a single-file format that holds a model's weights and a standard set of metadata, built to load quickly, as [Hugging Face's GGUF page](https://huggingface.co/docs/hub/gguf) puts it. On Apple silicon Macs, LM Studio can also run models with MLX, Apple's own machine learning framework, which uses separate MLX downloads.

The app's [overview page](https://lmstudio.ai/docs/app) lists what it covers. It downloads and runs open models such as gpt-oss, Llama and Qwen. It chats with them. It also connects MCP servers, which are tools a model can call through the Model Context Protocol, and serves OpenAI-like endpoints on your machine or across your network.

The app runs on all three desktop systems, and the requirements page sets the floor for each. On x64 Windows the processor must support AVX2, a CPU instruction set the builds depend on, and the x64 Linux build ships with AVX2 support by default. Downloads need an internet connection.

- macOS: Apple silicon (M1, M2, M3 or M4) and macOS 14.0 or newer. 16GB of RAM or more is recommended.
- Windows: x64 with AVX2, or ARM (Snapdragon X Elite). At least 16GB of RAM and 4GB of dedicated VRAM are recommended.
- Linux: Ubuntu 20.04 or newer, on x64 or ARM64. The app ships as an AppImage, a single file that runs without an installer.

**LM Studio releases that shaped this lesson**

1. **May 2, 2024** The lms command line. `lms` arrives with the app, to load models and run the server from a terminal.
2. **October 8, 2024** Apple MLX. Apple silicon Macs can run MLX models next to GGUF ones.
3. **June 25, 2025** MCP in LM Studio. LM Studio becomes an MCP host, so a model can call tools from servers you add.
4. **January 28, 2026** LM Studio 0.4.0. A headless core called llmster, parallel requests on llama.cpp, a stateful `/v1/chat` route and `lms daemon up`.
5. **July 16, 2026** LM Studio Bionic. A separate agent app for open models, beside LM Studio itself.
6. **September 18, 2026** Splash engine. An experimental backend in Bionic 1.1.5 or newer, for an M3 or newer Mac on macOS 26.4 or later with at least 36GB of unified memory.

Sources: [LM Studio blog: lms, the LM Studio CLI](https://lmstudio.ai/blog/lms) (read 2026-11-05), [LM Studio blog: LM Studio 0.3.4 ships with Apple MLX](https://lmstudio.ai/blog/lmstudio-v0.3.4) (read 2026-11-05), [LM Studio blog: MCP in LM Studio](https://lmstudio.ai/blog/lmstudio-v0.3.17) (read 2026-11-05), [LM Studio blog: LM Studio 0.4.0](https://lmstudio.ai/blog/0.4.0) (read 2026-11-05), [LM Studio blog: Introducing LM Studio Bionic](https://lmstudio.ai/blog/introducing-lm-studio-bionic) (read 2026-11-05), [LM Studio blog: Splash engine](https://lmstudio.ai/blog/splash-engine) (read 2026-11-05)

## Download a model and chat with it

Everything starts in the model search tab, which searches Hugging Face from inside the app. Press `⌘` + `2` on a Mac, or `Ctrl` + `2` on Windows and Linux, to jump there from anywhere. You can search by keyword, by a `user/model` name, or by pasting a full Hugging Face address.

Each model comes in several download options, with names like `Q3_K_S` or `Q8_0`. They are copies of the same model at different levels of quantization, which shrinks the file by storing each weight in fewer bits and costs some quality. The [download page](https://lmstudio.ai/docs/app/basics/download-model) advises a 4-bit option or higher if your machine can run it. [Lesson 4](https://mindket.com/learn/local-ai/local-llm-hardware) turns those labels into gigabytes. Until then, compare file sizes with your free memory.

Downloading and loading are separate steps. Loading puts the weights into memory. The model loader at the top of the Chat tab does it, and you can set load parameters first. Two of them also appear as flags on `lms load`: the share of work given to the GPU and the context length, which is how much text the model can hold at once.

Attach a `.docx`, `.pdf` or `.txt` file to a chat and the model answers from it. A short file goes into the conversation whole, as long as it fits in the model's context. The documents page calls context the model's working memory and counts it in tokens, at about three quarters of a word each. Whole files work best with models that take a long context, and the page names Llama 3.1 and Mistral Nemo. A long one switches LM Studio to retrieval: it picks out the passages that look relevant and hands the model only those. Your question steers what it finds. The [same page](https://lmstudio.ai/docs/app/basics/rag) suggests putting into your question the terms you expect the answer to contain, and the [RAG course](https://mindket.com/learn/rag/rag-tutorial) builds the same retrieval in code.

1. Download the installer for your system from [LM Studio's Downloads page](https://lmstudio.ai/download) and install it. On Linux the download is an AppImage.
2. Open the model search tab and look for a model, for example `gemma` or `llama`.
3. Choose a download option at 4-bit or higher that fits your memory, and download it.
4. Open the Chat tab, open the model loader, select the model and load it.
5. Ask a question. To work with a file, attach it to the chat and ask about what it says.

## Run the local server for your code

The server turns the loaded model into an OpenAI-style API. In the app, open the Developer tab and switch on Start server. From a terminal, `lms server start` does the same. Its [options](https://lmstudio.ai/docs/cli/serve/server-start) are `--port` to choose a port and `--cors` to let web pages call the server. Without `--port` it reuses the last port. Any free port works.

LM Studio's examples use port `1234`, so the base URL is `http://localhost:1234/v1`. The routes are `GET /v1/models` and, for `POST`, `/v1/chat/completions`, `/v1/responses`, `/v1/completions` and `/v1/embeddings`. The `model` field takes the identifier LM Studio shows for the loaded model. Codex, OpenAI's coding agent, can use the server because LM Studio implements `POST /v1/responses`.

The code is LM Studio's own chat completions example. If you wrote code against Ollama's `/v1` route in [lesson 2](https://mindket.com/learn/local-ai/ollama-api), the same client works here with a different base URL. The key is a placeholder, and the system message travels in `messages` like any other.

The chat completions page adds that LM Studio applies the prompt template on its own for chat-tuned models. A prompt template is the wrapping of special tokens a model was trained to expect around each message, so your code sends plain roles and text.

A request does not need a model you loaded by hand. With JIT loading, short for just-in-time, the server loads the model a request names. Idle TTL is how long such a model stays in memory with no requests, and the [TTL page](https://lmstudio.ai/docs/developer/core/ttl-and-auto-evict) sets it at 60 minutes by default. Auto-Evict unloads the last JIT-loaded model before it loads a new one. A request can carry its own `ttl` in seconds.

Out of the box the server accepts requests with no key. Authentication is a switch in Server Settings on the Developer page, and tokens come from its Manage Tokens button. Copy a new token straight away, because the app shows it only once. With the switch on, the docs say calls through the REST API and the two SDKs need a valid token, sent as a bearer token in the `Authorization` header.

Other devices on your network can reach the server through the Serve on Local Network setting, or with `lms server start --bind 0.0.0.0`. The [network page](https://lmstudio.ai/docs/developer/core/server/serve-on-network) warns that any bind other than `127.0.0.1` exposes the server beyond your computer, and it recommends turning on authentication. The uses it names include a strong machine serving weaker ones and one copy shared by several people.

The OpenAI routes are not the only way in. The same server speaks an Anthropic-compatible format and LM Studio's own REST API, and LM Studio publishes SDKs for Python and TypeScript, `lmstudio-python` and `lmstudio-js`.

````python
from openai import OpenAI

client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")

completion = client.chat.completions.create(
  model="model-identifier",
  messages=[
    {"role": "system", "content": "Always answer in rhymes."},
    {"role": "user", "content": "Introduce yourself."}
  ],
  temperature=0.7,
)

print(completion.choices[0].message)
````

## Drive LM Studio from the terminal with lms

The `lms` command ships with LM Studio. There is nothing more to install. Start the app at least once, then run `lms --help` to check it works.

If you took lesson 1, the commands look familiar, with one difference: loading is its own step. You download with `lms get`, put a model in memory with `lms load` and talk to it with `lms chat`. Ollama does the loading inside `ollama run`. LM Studio keeps it apart.

Scripts lean on the load flags. The `--gpu` flag takes a fraction from `0` to `1`, `max` for every layer or `off` for none, and LM Studio picks for you when you leave it out. The `--context-length` flag sets the context. The `--identifier` flag gives the loaded model a fixed name, so the `model` field in your code keeps working when you swap the file behind it. A model loaded this way has no TTL until you add one, as in `--ttl 3600` for an idle hour.

Two more commands matter on a machine without a screen. The `lms daemon up` command starts the headless daemon, a background service with no app window. The `lms runtime` command manages and updates the inference runtime, the engine that runs the models.

Downloads take a quantization after an @ sign, as in `lms get llama-3.1-8b@q4_k_m`, and `--mlx` or `--gguf` limits the search to one format. Models fetched this way land in the same folder as the app's downloads. When code gets a strange answer, `lms log stream` prints the messages going in and out of the model.

````bash
lms get llama-3.1-8b@q4_k_m        # download one quantization
lms ls                             # models on disk
lms load openai/gpt-oss-20b --identifier="my-model-name"
lms ps                             # models in memory
lms server start --port 3000       # the API server, on a port you choose
lms log stream                     # watch requests and replies
lms unload --all
````

| lms | What it does | Closest Ollama command |
| --- | --- | --- |
| `lms get` | Searches and downloads models | `ollama pull` |
| `lms ls` | Lists the models on disk | `ollama ls` |
| `lms load` | Loads a model into memory | `ollama run`, which loads as it opens a chat |
| `lms ps` | Lists the models loaded in memory | `ollama ps` |
| `lms unload` | Unloads a model, or all of them with `--all` | `ollama stop` |
| `lms chat` | Starts an interactive chat | `ollama run` |
| `lms server start` | Starts the local API server | `ollama serve` |
| `lms import` | Imports a model file into LM Studio | No single command |
| `lms runtime` | Manages and updates the inference runtime | No single command |

## What Qwen's team says a 9B model needs in LM Studio

Alibaba's Qwen team, which publishes open foundation models, posted [on X](https://x.com/Alibaba_Qwen/status/2028664203872251943) in March that Qwen3.5-9B had arrived in LM Studio and needed only about 7GB to run locally. The post quotes LM Studio's own announcement, which adds that the model takes images as input, can think and calls tools.

About 7GB is the download, not the whole bill. The context takes memory on top of the file, so a machine that holds the file with little to spare can still run short in a long chat or with a big document.

To try it, search for Qwen3.5-9B in the model search tab and pick an option whose size leaves a few gigabytes free. Load it, open your system's memory monitor and compare what it uses with the figure in the post, then do the same after a long conversation.

> Qwen3.5-9B is now available on LM Studio. Requires only ~7GB to run locally
>
> Qwen, Alibaba's Qwen team account, which publishes open foundation models, [X](https://x.com/Alibaba_Qwen/status/2028664203872251943) (read 2026-11-05)

[![Qwen (@Alibaba_Qwen) on X, 3 March 2026: Qwen3.5-9B is now available on LM Studio, and requires only about 7GB to run locally. It quotes LM Studio's post saying the model takes images as input, can think and calls tools.](https://mindket.com/blog/shots/x-alibaba-qwen-lm-studio-9b.webp?v=0439295b9370)](https://x.com/Alibaba_Qwen/status/2028664203872251943)

Qwen on X, 3 March 2026

> A screenshot of X's own embed of the post, taken on 5 November 2026, with the time in UTC. Select it to open the post on X.

## Common mistakes

- Picking the largest download option because it sounds best. Every option is the same model, and the bigger files need more memory to load.
- Sending a `model` value that does not match the identifier LM Studio shows. Copy it from the app, or fix it yourself with `--identifier`.
- Running `lms` on a machine where the app has never started. The docs ask for one launch first.
- Installing an MCP server from a source you do not trust. LM Studio's MCP page warns that some servers can run arbitrary code, read your local files and use your network.
- Expecting a JIT-loaded model to free its memory as soon as a reply ends. It stays for its idle TTL, an hour by default.
- Asking a vague question about a long attached file. Retrieval only hands the model the passages it found, so name the terms the answer should contain.
- Turning on `--cors` for a server that only your scripts call. CORS, short for cross-origin resource sharing, is the browser rule that lets a web page on another address reach the server, and a script never needs it.

## Try it yourself

- Download a 4-bit and an 8-bit option of one model and compare their sizes in My Models.
- Ask the same question about a one-page note and a long PDF, using the words you expect in the answer.
- Start the server, call `curl http://localhost:1234/v1/models` and copy an identifier into the Python example.
- Load a model with `--identifier`, then point the Python example at that name.
- Run `lms log stream` in one terminal while the Python example runs in another, and read what was sent.
- With JIT loading on, name a model you have not loaded in a request, then look for it in `lms ps`.

> Next: both tools offered one model in several sizes and asked how much of it to put on the GPU. [Lesson 4](https://mindket.com/learn/local-ai/local-llm-hardware) works out which model and which quantization fit your computer, starting from the parameter count.

## Check yourself

1. On Windows, which shortcut opens the model search in LM Studio?

   A. Ctrl + S
   B. Ctrl + M
   C. Ctrl + 2
   D. Ctrl + D

   Answer: C. Ctrl + 2 on Windows and Linux, or ⌘ + 2 on a Mac, opens the tab that searches Hugging Face from inside the app.

2. Which download option does LM Studio suggest if your machine can run it?

   A. A 4-bit option or higher
   B. The smallest file available
   C. Always the full 16-bit file

   Answer: A. The download page advises a 4-bit option or higher when the machine is capable enough.

3. Your Python code reaches the server but names the wrong model. What fixes it for good?

   A. Turning on --cors
   B. Restarting the app
   C. Raising the context length
   D. Loading the model with --identifier and using that name

   Answer: D. A fixed identifier keeps the model field working even when you swap the file behind it.

4. What happens to a long PDF attached to a chat?

   A. LM Studio uploads it for processing
   B. LM Studio retrieves the relevant passages and gives the model those
   C. The chat refuses the file
   D. The whole file is always pasted into the context

   Answer: B. A file too long for the context switches LM Studio to retrieval, and the document stays on your machine.

## Frequently asked questions

### Does LM Studio work offline?

Yes, for everything except fetching things. Chats and attached documents stay on your machine and work with no connection. Searching for models, downloading them and updating the app or its runtimes need the internet, and the app checks for updates when it opens.

### Is LM Studio better than Ollama?

They overlap more than they differ. Both run GGUF models through llama.cpp and serve an OpenAI-compatible API on your machine. LM Studio puts a model browser and a chat window in front, with documents you can attach. Ollama is built around its command line, its own API and a library of named tags.

### Can LM Studio use MCP servers?

Yes, since version 0.3.17, when it became an MCP host. Open the Program tab in the right-hand sidebar, choose Install, then Edit mcp.json, and add servers in the `mcpServers` format. [What is MCP](https://mindket.com/blog/what-is-mcp) explains what those servers add to a model.

### Where does LM Studio store downloaded models?

In its models directory, which you can see and change under My Models. Models you fetch with `lms get` go to the same folder, and Hugging Face model pages offer LM Studio under "Use this model" for GGUF and MLX files.

## Sources

- [LM Studio Docs: Welcome to LM Studio](https://lmstudio.ai/docs/app) (read 2026-11-05)
- [LM Studio Docs: System requirements](https://lmstudio.ai/docs/app/system-requirements) (read 2026-11-05)
- [LM Studio Docs: Get started](https://lmstudio.ai/docs/app/basics) (read 2026-11-05)
- [LM Studio Docs: Download an LLM](https://lmstudio.ai/docs/app/basics/download-model) (read 2026-11-05)
- [LM Studio Docs: Chat with documents](https://lmstudio.ai/docs/app/basics/rag) (read 2026-11-05)
- [LM Studio Docs: Offline operation](https://lmstudio.ai/docs/app/offline) (read 2026-11-05)
- [LM Studio Docs: Use MCP servers](https://lmstudio.ai/docs/app/mcp) (read 2026-11-05)
- [LM Studio Docs: Local server](https://lmstudio.ai/docs/developer/core/server) (read 2026-11-05)
- [LM Studio Docs: Idle TTL and Auto-Evict](https://lmstudio.ai/docs/developer/core/ttl-and-auto-evict) (read 2026-11-05)
- [LM Studio Docs: Authentication](https://lmstudio.ai/docs/developer/core/authentication) (read 2026-11-05)
- [LM Studio Docs: Serve on Local Network](https://lmstudio.ai/docs/developer/core/server/serve-on-network) (read 2026-11-05)
- [LM Studio Docs: OpenAI compatibility](https://lmstudio.ai/docs/developer/openai-compat) (read 2026-11-05)
- [LM Studio Docs: Chat completions](https://lmstudio.ai/docs/developer/openai-compat/chat-completions) (read 2026-11-05)
- [LM Studio Docs: lms CLI](https://lmstudio.ai/docs/cli) (read 2026-11-05)
- [LM Studio Docs: lms server start](https://lmstudio.ai/docs/cli/serve/server-start) (read 2026-11-05)
- [LM Studio Docs: lms get](https://lmstudio.ai/docs/cli/local-models/get) (read 2026-11-05)
- [LM Studio Docs: lms load](https://lmstudio.ai/docs/cli/local-models/load) (read 2026-11-05)
- [Hugging Face Docs: GGUF](https://huggingface.co/docs/hub/gguf) (read 2026-11-05)
- [Hugging Face Docs: Use AI models locally](https://huggingface.co/docs/hub/local-apps) (read 2026-11-05)
- [LM Studio blog: lms, the LM Studio CLI](https://lmstudio.ai/blog/lms) (read 2026-11-05)
- [LM Studio blog: LM Studio 0.3.4 ships with Apple MLX](https://lmstudio.ai/blog/lmstudio-v0.3.4) (read 2026-11-05)
- [LM Studio blog: MCP in LM Studio](https://lmstudio.ai/blog/lmstudio-v0.3.17) (read 2026-11-05)
- [LM Studio blog: LM Studio 0.4.0](https://lmstudio.ai/blog/0.4.0) (read 2026-11-05)
- [LM Studio blog: Introducing LM Studio Bionic](https://lmstudio.ai/blog/introducing-lm-studio-bionic) (read 2026-11-05)
- [LM Studio blog: Splash engine](https://lmstudio.ai/blog/splash-engine) (read 2026-11-05)
- [Qwen on X: Qwen3.5-9B is now available on LM Studio](https://x.com/Alibaba_Qwen/status/2028664203872251943) (read 2026-11-05)

[Browse MCP servers](https://mindket.com/mcp-servers)
