The AI Loadout

Best Local LLM Setup for Coding: Ollama vs LM Studio

Published · Updated

By The AI Loadout editors · How we pick · Nichelogix, LLC

This guide is a practical comparison, not a promise that one tool fits every workflow. Check the linked sources and your own limits before you connect an account or buy a plan.

Pick Ollama if you work in a terminal and want one-command launchers for Claude Code, Codex and OpenCode. Pick LM Studio if you want a desktop app to browse, test and load models. Both serve local OpenAI-compatible APIs (Ollama on port 11434, LM Studio on 1234), so most coding tools work with either.

Which one should you pick

Both tools are free, both run open models on your own hardware, and both expose a local HTTP API that coding tools already understand. So the choice is about how you like to work, not about capability.

Ollama is MIT licensed and built around the command line. You pull a model by tag, run it with one command, and it serves an API on http://localhost:11434. It also has ollama launch, which configures and starts a coding agent for you: Claude Code, OpenCode, Codex, VS Code and Droid are the integrations its CLI reference lists.

LM Studio is a desktop app: a Discover tab that searches and downloads models from Hugging Face, a chat window, a Developer tab that runs the local server on port 1234, and an lms command line tool that ships with the app. It runs llama.cpp GGUF models everywhere and MLX models on Apple Silicon, and you can set load options such as context length per model. LM Studio's app is free to use at home and at work under its terms.

Running both at once is fine. They use different ports and different model folders, so a Gemma download in LM Studio does not conflict with an Ollama pull of the same model.

  • Choose Ollama for: shell workflows, headless or remote boxes, ollama launch into an agent, and the Ollama library's size and context listings for each tag.
  • Choose LM Studio for: a GUI you can browse and chat in, Hugging Face model search, per-model load settings, and a visible Developer server you can switch on when your editor needs it.
  • Either is fine for coding agents, because both answer OpenAI-compatible requests on localhost.

The short list

If you want the decision without the detail, start here, then skip to the install section for the runtime you picked.

  1. Ollama (terminal and agents): MIT licensed runner on port 11434, with ollama launch for Claude Code, OpenCode and Codex.
  2. LM Studio (desktop app): Desktop app with a model browser, chat and per-model load settings, serving OpenAI and Anthropic compatible routes on port 1234.
  3. Gemma 4 E4B (16 GB starter): 6.6 GB download with a 128K context window, in both the Ollama library and the LM Studio catalog.
  4. Qwen 3.5 9B (16 GB, mostly code): 6.6 GB download with a 256K context window and tool calling.
  5. Devstral Small 2 24B (24 to 32 GB agents): 15 GB coding agent model with tool use and a 384K context window.

Install and run Ollama

Download the app for macOS or Windows from ollama.com, or install on Linux with the official script. The latest release on GitHub is v0.40.6, published October 16, 2026. macOS needs Sonoma (14) or newer; Windows needs 10 22H2 or newer.

Pull a model, run it, and you have both a chat in your terminal and an API on port 11434.

Install on Linux
curl -fsSL https://ollama.com/install.sh | sh
Pull a model and chat
ollama pull gemma4:e4b
ollama run gemma4:e4b
Check the OpenAI-compatible endpoint
curl -X POST http://localhost:11434/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{"model":"gemma4:e4b","messages":[{"role":"user","content":"Say hello in one sentence."}]}'

OpenAI clients use the base URL http://localhost:11434/v1/ with any api_key value; the client requires one and Ollama ignores it. The native API lives at http://localhost:11434/api/chat.

One setting decides whether coding agents feel usable: context length. Ollama picks a default from your VRAM: 4K below 24 GiB, 32K from 24 to 48 GiB, and 256K above that. Its docs say coding tools and agents should run at 64,000 tokens or more. Set it with OLLAMA_CONTEXT_LENGTH=64000 ollama serve or the slider in the app's settings, then run ollama ps. PROCESSOR should read 100% GPU, and CONTEXT shows the window you actually got.

On a Mac, the Ollama library also lists MLX builds for many models, such as qwen3.8:27b-mlx. To stay fully local, pick local tags rather than cloud ones; setting OLLAMA_NO_CLOUD=1 turns Ollama's cloud features off entirely.

Install and run LM Studio

Download LM Studio from lmstudio.ai/download. The download page lists version 0.4.26 of the app. Requirements: an Apple Silicon Mac on macOS 14 or newer (Intel Macs are not supported), a Windows x64 CPU with AVX2 or a Snapdragon X Elite ARM PC, or x64 or ARM64 Linux, where it ships as an AppImage for Ubuntu 20.04 or newer. LM Studio recommends 16 GB of RAM, and on a PC at least 4 GB of dedicated VRAM.

In the app, press Cmd+2 (Ctrl+2 on Windows and Linux) to open Discover, search for a model such as Gemma 4 E4B, choose a 4-bit or higher quantization, and download it. Then open the Developer tab, load the model and switch the server on. The same steps are scriptable with lms, which is installed with the app and works once you have opened LM Studio at least once.

The download page also offers LM Studio Bionic, a separate agent app. Its free plan runs local models, and paid plans from $20 a month add hosted open models. Nothing in this guide needs it.

Download, load with a bigger context, and serve
lms get google/gemma-4-e4b
lms load google/gemma-4-e4b --context-length 65536 --gpu max
lms server start --port 1234
Headless machine (llmster daemon)
curl -fsSL https://lmstudio.ai/install.sh | bash
lms daemon up

OpenAI-compatible routes sit under http://localhost:1234/v1, including /v1/chat/completions and /v1/responses (which Codex uses). LM Studio also serves Anthropic's Messages format at /v1/messages, which is what Claude Code needs. Its agent guides ask for more than about 25K of context, because coding tools fill it quickly.

Handy commands: lms ls lists models on disk, lms ps shows what is loaded, and lms load --estimate-only <model> --context-length 65536 prints a memory estimate before you load anything. If the model lives on a bigger machine, LM Studio's LM Link lets Claude Code or Codex run on your laptop against it.

Wire your coding tools to either runtime

Every setup below comes from the tool's or the runtime's own documentation, checked in October 2026. Start the runtime first, load a model, then configure the tool.

Continue in VS Code or JetBrains

Continue reads a YAML config with a models list. Use provider: ollama or provider: lmstudio. The LM Studio provider defaults to http://localhost:1234/v1, and the Ollama provider only needs apiBase when the server is on another machine. If tool calling or image input is not detected for a custom tag, add a capabilities list with tool_use or image_input.

Continue with Ollama
name: Local coding
version: 0.0.1
schema: v1
models:
  - name: Gemma 4 E4B (Ollama)
    provider: ollama
    model: gemma4:e4b
    # apiBase: http://localhost:11434   # only for a remote server
Continue with LM Studio
name: Local coding
version: 0.0.1
schema: v1
models:
  - name: Gemma 4 E4B (LM Studio)
    provider: lmstudio
    model: google/gemma-4-e4b
    # apiBase: http://localhost:1234/v1  # this is the default

Cline

Cline has a provider for each runtime, so there is nothing to hand-write. Open Cline settings, set API Provider to Ollama with base URL http://localhost:11434, or to LM Studio with base URL http://localhost:1234, then pick your model from the dropdown. No API key is needed for either.

Two settings matter for local models. Turn on Use Compact Prompt under Features, which swaps in a much shorter system prompt, and raise the context window: Ollama's Cline guide asks for at least 32K tokens for coding.

OpenCode

With Ollama installed, run OpenCode with ollama launch opencode from your project directory. Ollama offers to install OpenCode if it is missing, and it passes an inline config for the model you select without overwriting your own opencode.json.

To configure it by hand, or to use LM Studio, add an OpenAI-compatible provider to opencode.json. OpenCode's provider docs show this shape for Ollama at port 11434 and for LM Studio at http://127.0.0.1:1234/v1; model ids must match what the server lists. Ollama's guide says OpenCode needs a context length of 64K or more.

opencode.json for a local runtime
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (local)",
      "options": { "baseURL": "http://localhost:11434/v1" },
      "models": { "qwen3.5:9b": { "name": "Qwen 3.5 9B" } }
    }
  }
}

Claude Code

Claude Code talks to an Anthropic Messages endpoint, and both runtimes provide one. With Ollama, ollama launch claude does the whole setup and offers to install Claude Code if needed. The manual path sets three environment variables and then picks a model.

With LM Studio, start the server and point the same variables at port 1234. Its docs use ANTHROPIC_AUTH_TOKEN=lmstudio and also set CLAUDE_CODE_ATTRIBUTION_HEADER=0. Pass a model id you have loaded. If you turned on Require Authentication in LM Studio, use your LM Studio API token as the auth token instead.

Claude Code through Ollama
ollama launch claude --model qwen3.5

# manual equivalent
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_API_KEY=""
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3.5
Claude Code through LM Studio
lms server start --port 1234
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
claude --model openai/gpt-oss-20b

Ollama's guide says to give Claude Code a 64K or larger context window, and more for a big repository.

Codex CLI

Codex CLI has a built-in local mode. Pass --oss and it uses a local provider, with --local-provider ollama or --local-provider lmstudio to choose when both are installed. You can set the default in ~/.codex/config.toml with oss_provider = "ollama" or "lmstudio". Without either, interactive Codex asks and codex exec errors out.

With Ollama, install Codex first (npm install -g @openai/codex), then ollama launch codex sets up a dedicated Codex profile and refreshes the model catalog, and /model inside Codex switches between your installed tool-capable models. With LM Studio, codex --oss defaults to openai/gpt-oss-20b and downloads it if needed, or you can pass -m with another model you have.

Codex against a local model
# Ollama
ollama launch codex
# or
codex --oss --local-provider ollama -m gpt-oss:20b

# LM Studio, server already running on :1234
codex --oss --local-provider lmstudio -m openai/gpt-oss-20b

Which local coding model at which memory tier

Budget roughly the download size plus 2 to 4 GB for context. On a Mac that comes out of unified memory; on a PC it should sit in GPU VRAM or generation slows down. Download sizes below are the Ollama library's listings, and the "minimum" figures are the minimum system memory LM Studio lists for its build.

  • 8 GB: Gemma 4 E2B (4.6 GB, 128K context) or Ministral 3 3B (3.0 GB). Expect explanations and small edits, not multi-file agent work.
  • 16 GB: Gemma 4 E4B is the balanced starter (6.6 GB, 128K; LM Studio lists a 6 GB minimum), run as gemma4:e4b in Ollama or google/gemma-4-e4b in LM Studio. For mostly code, Qwen 3.5 9B (6.6 GB, 256K; 7 GB minimum). gpt-oss 20B (14 GB; 12 GB minimum) fits if little else is open.
  • 24 to 32 GB: this tier fits the models built for agent work. Devstral Small 2 24B is built for this job, with tool use and a 384K context window (15 GB; 16 GB minimum). Qwen3-Coder 30B is the other coding-specific pick: 30B parameters with 3.3B active, 256K context (19 GB; 15 GB minimum). General models with tool calling: Qwen 3.8 27B (18 GB), Qwen 3.5 27B (17 to 20 GB) and Gemma 4 26B (16 to 19 GB). For speed, LFM2.5 24B-A2B (15 GB) runs only about 2B parameters per token; it is in Ollama but not yet in LM Studio's catalog.
  • 48 GB and up: Llama 3.3 70B (43 GB) or gpt-oss 120B (65 GB). Ollama defaults to a 256K context window once you have 48 GiB of VRAM or more.

The full tier tables, licenses and alternatives are on how to run AI locally, and each model above has a page in the models directory. A local model does not have to do everything. The Agent Project Manager skill in our skill packs scores each task and routes it to the cheapest model that can do it, from local Gemma 4 up to frontier cloud models.

What usually goes wrong

Most trouble with a first local coding setup is configuration, not the model. Check these three things first.

Context too small. A 4K window cannot hold a repo map plus a diff. Raise it on the runtime (OLLAMA_CONTEXT_LENGTH=64000, or lms load --context-length) and in the tool's own setting, since Cline and Continue each have their own context field.

The model cannot call tools. Agents depend on tool calling, so pick a model that advertises it. Ollama's library tags models with tools, and LM Studio's catalog shows Trained for tool use.

Half the model is on the CPU. ollama ps shows the CPU and GPU split, and lms load --gpu max pushes layers onto the GPU. If a model will not fit, drop to a smaller size instead of accepting a split load.

Ready skill packs

The AI Loadout sells ready skill packs you can install with one terminal command after purchase. No refunds (all sales final) because packs are downloadable. If install fails, support@theailoadout.com will help fix it.

Browse skill packs

FAQ

Is Ollama or LM Studio better for coding?

Neither wins outright. Ollama is better if you want CLI installs and one-command launchers for Claude Code, OpenCode and Codex. LM Studio is better if you want a GUI to browse, chat with and configure models before wiring them into an editor. Both serve local APIs that coding tools support.

What ports do Ollama and LM Studio use?

Ollama serves http://localhost:11434, with OpenAI-compatible routes under /v1. LM Studio serves http://localhost:1234, also with /v1 routes, and you can change it with lms server start --port. Because the ports differ, you can run both at the same time.

Can Claude Code use a local model?

Yes. With Ollama, run ollama launch claude, or set ANTHROPIC_BASE_URL=http://localhost:11434 with ANTHROPIC_AUTH_TOKEN=ollama and an empty ANTHROPIC_API_KEY. With LM Studio, set ANTHROPIC_BASE_URL=http://localhost:1234 and ANTHROPIC_AUTH_TOKEN=lmstudio, which hits its Anthropic-compatible /v1/messages endpoint.

Can Codex CLI use Ollama or LM Studio?

Yes. Pass --oss, and add --local-provider ollama or --local-provider lmstudio when both are installed, or set oss_provider in ~/.codex/config.toml. Ollama also has ollama launch codex, which creates a Codex profile for you. Ollama's docs recommend at least a 64K context window for Codex.

Which local model should I start with for coding on a 16 GB laptop?

Gemma 4 E4B as the all-rounder (ollama run gemma4:e4b, or google/gemma-4-e4b in LM Studio), or Qwen 3.5 9B if most of your work is code. Both are about a 6.6 GB download. Raise context toward 32K or 64K before judging how well an agent handles your repo.

Are Ollama and LM Studio free?

Ollama is open source under the MIT license. LM Studio's app is free to use at home and at work under its terms. LM Studio Bionic, its separate agent app, has a free plan for local models and paid plans from $20 a month for hosted models, which you do not need for local coding.

Do I have to choose one?

No. You can keep LM Studio for browsing and chatting with models and use Ollama for agents and scripts. The ports differ, so they do not conflict, but each keeps its own model folder, so a model downloaded in both takes up disk space twice.

Sources

Disclosure: product links on this page go to The AI Loadout packs we sell. Affiliate and sponsored links elsewhere on the site are always labeled and do not change our picks. Read our methodology.

Related