How to connect LM Studio local server to VS Code Continue extension
The core of this setup is that LM Studio mimics the OpenAI API format, which makes it compatible with almost any tool designed for GPT-4.
Step 1: Prime the LM Studio Server
Load the model you want to use (I recommend DeepSeek-Coder-V2 or Llama-3.1-8B for a balance of speed and logic). Click the double-arrow icon on the left sidebar to open the Local Server tab. Ensure the server is started. You will see a URL, typically http://localhost:1234. Keep this window open; if you shut down LM Studio, the connection in VS Code will break.
Step 2: Configuring Continue.json
Once the Continue extension is installed in VS Code, you need to tell it where to look for the model. Open the config.json file by clicking the gear icon in the Continue sidebar.
You need to add a new model entry to the models array. Here is exactly how the configuration block should look:
{
"models": [
{
"title": "LM Studio - Local",
"model": "local",
"apiBase": "http://localhost:1234/v1",
"provider": "openai"
}
],
"tabAutocompleteModel": {
"title": "LM Studio Autocomplete",
"model": "local",
"apiBase": "http://localhost:1234/v1",
"provider": "openai"
}
}Critical Config Details:
- apiBase: Notice the
/v1at the end. If you omit this, the connection will likely fail with a 404 error because Continue expects the OpenAI-style versioning path. - provider: Set this to
openai. Even though you aren't using OpenAI, LM Studio is acting as an OpenAI-compatible proxy.
The "Gotchas" and Performance Tuning
If you find the responses are sluggish or cutting off, check your GPU offloading settings in LM Studio. If you're on a Mac M-series or an NVIDIA card, crank the GPU layers up to the max.
One common point of frustration is the "Context Window." By default, LM Studio might set a limit (like 2048 or 4096 tokens). If you are asking Continue to analyze a large file, the model will "forget" the top of the file. Increase the Context Length in the LM Studio right-hand settings panel to 16k or 32k, provided your VRAM can handle it.
My Productivity Workflow
I use a hybrid approach. I keep a fast, small model (like Phi-3) running in LM Studio for the tabAutocompleteModel setting because it's nearly instantaneous. For the main chat window in Continue, I switch to a heavier model or a cloud-based Claude 3.5 Sonnet when the local model hits a logic wall. This way, I get the speed of local autocomplete with the intelligence of a frontier model for complex refactoring.
If the connection drops, don't waste time debugging the JSON. Usually, it's just the LM Studio server having timed out or a port conflict. A quick restart of the server in LM Studio usually fixes 90% of the issues.
All Replies (0)
No replies yet — be the first!
