Skip to content
All posts
2 min read

How to Connect a Coding Agent to a Local Model in LM Studio

Amit Raz

Amit Raz

Founder, RZ AI Labs

A few people asked how to connect a coding agent to a model served by LM Studio. It is very, very simple: load the model in LM Studio, copy its local URL, and register it as a custom endpoint in your editor. Here are the exact steps.

This post is part of a local LLM series: the coding capability test, the configuration guide, and where local models actually earn their keep.

Step 1: LM Studio side

  1. Search for the model you want and download it
  2. Switch to the LLMs tab and load it
  3. Look at the URL LM Studio exposes for the model and copy it

LM Studio serves an OpenAI-compatible API on localhost, typically http://127.0.0.1:1234/v1.

Step 2: VS Code side

  1. Click the model picker at the bottom, then the gear icon
  2. Choose Add Models, then Custom Endpoint
  3. Give the group a name, skip the API key, and choose Chat completions
  4. You get the JSON for the model settings; the important part is pointing the URL at LM Studio

Mine looks like this:

"models": [
  {
    "id": "google/gemma-4-26b-a4b",
    "name": "GemmaLocal",
    "url": "http://127.0.0.1:1234/v1",
    "toolCalling": true,
    "vision": true,
    "thinking": false,
    "temperature": 1,
    "maxInputTokens": 32768,
    "maxOutputTokens": 8192
  }
]

Close and save, and the next time you click the model picker, your local model is there. That is all.

The part people underestimate

The endpoint is the plumbing. The configuration is the difference between a model that hangs and a model that works.

The values in that JSON, and the matching settings inside LM Studio, change behavior dramatically: context length, token caps, temperature, tool calling. Getting them right per task is a separate discipline, and I wrote a full guide on configuring the same model differently for different jobs. If you are setting up local models as part of a bigger agent workflow, that is the kind of thing I help teams with in hands-on AI workshops.

FAQ

What URL does LM Studio expose for local models?

LM Studio serves an OpenAI-compatible endpoint on localhost, typically http://127.0.0.1:1234/v1. Load a model in the LLM tab, copy the URL it shows, and any tool that speaks the chat completions API can use it.

Why does my local model behave badly with a coding agent?

Nine times out of ten it is the configuration, not the model. Context length, token limits, temperature, and tool-calling flags all change behavior dramatically. The endpoint JSON is only the plumbing; tuning the settings per task is a separate job worth doing properly.

Building something with AI?

I help teams ship custom agents, AI strategy, and software that works.