Skip to content
| Marketplace
Sign in
Visual Studio Code>Machine Learning>LM Studio Copilot ProviderNew to Visual Studio Code? Get it now.
LM Studio Copilot Provider

LM Studio Copilot Provider

Mikhail Kashin

|
346 installs
| (2) | Free
Dynamic LM Studio chat provider with automatic model loading.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

LM Studio Copilot Provider

LM Studio Copilot Provider — local models in Copilot Chat for VS Code

Use models served by LM Studio in GitHub Copilot Chat inside VS Code. Connect a local computer or several servers, select a model from the standard Copilot model picker, and chat or work with an agent.

Quick start ? Remote servers ? Settings ? Troubleshooting

Features at a glance

  • Local and remote servers. Connect multiple LM Studio instances, each with its own address and optional API token.
  • Automatic model discovery. Available chat models appear under LM Studio; the list refreshes in the background.
  • Load on demand. An unloaded model is loaded when its first request arrives. Exclusive switching unloads other chat models on the same server by default; it can be disabled in settings.
  • Agent tools and images. Tool calling and image input are exposed when LM Studio advertises support for the selected model.
  • Reasoning controls. View streamed reasoning and select the effort level supported by each model.
  • Context tracking and compaction. See actual usage after a response and use Copilot's automatic compaction or manual /compact.
  • Conversation continuity. Reuse stored responses and prompt cache when supported; recover from selected empty, interrupted, or malformed responses.

Model capabilities and response quality depend on the model, LM Studio runtime, and Copilot version. Embedding models are excluded from the chat picker.

Requirements

  • VS Code 1.134 or later, with GitHub Copilot Chat installed and enabled.
  • LM Studio with a downloaded chat model and a running API server. The server must provide the native /api/v1/models API and OpenAI-compatible /v1/responses endpoint. The provider also uses native model load/unload endpoints and a Chat Completions compatibility path for selected models.
  • Enough RAM/VRAM to load the model with your chosen context size.

VS Code must be able to reach the server. When VS Code and LM Studio run on different computers, use the LM Studio computer's network address instead of 127.0.0.1.

Quick start

1. Start LM Studio

  1. Install and open LM Studio.
  2. Download a chat/instruct model. For agent work, choose one with tool-use support; for image input, choose a vision model.
  3. Open the Developer tab and turn on Start server. The default address is http://localhost:1234.
  4. For the first connection, load the model in LM Studio and choose a context size that fits your hardware. Later, the extension can load it automatically.

If the LM Studio CLI is available, you can also start the server with:

lms server start

See LM Studio's server guide for server startup options.

2. Install the provider

Install LM Studio Copilot Provider by MikhailKashin from VS Code's Extensions view, or install a downloaded .vsix using Extensions: Install from VSIX... in the Command Palette.

Run Developer: Reload Window after installation or an update so the Extension Host loads the installed version.

3. Connect VS Code

Open Preferences: Open User Settings (JSON) from the Command Palette and add this property to your existing settings:

{
  "lmStudio.instances": [
    {
      "name": "Local",
      "url": "http://127.0.0.1:1234"
    }
  ]
}

Use the server root address for url. Do not append /v1, /api/v1, or /responses; the extension adds endpoint paths itself. Replace port 1234 if your server uses another port.

Save the settings. Changes trigger discovery immediately. You can also run LM Studio: Refresh Models from the Command Palette.

4. Select a model and send a message

  1. Open Copilot Chat.
  2. Open its model picker and select a model under LM Studio.
  3. Send a short prompt, such as Reply with OK.
  4. For workspace tasks, select Agent mode and a model that supports tool calling.

If automatic loading is enabled, the first request may take longer while LM Studio loads the model. Once a response completes, inspect the model's details/tooltip for context usage and token counts.

Remote servers and authentication

Connect another computer

On the LM Studio computer, enable Serve on Local Network in the server settings. Use the address displayed by LM Studio and allow the server port through that computer's firewall if needed. See the local-network guide.

For a server that requires authentication, create an API token in LM Studio and put its value in the instance's apiKey field. Enter the token without the Bearer prefix; the extension adds it to requests. See the LM Studio API authentication instructions.

Example with a local server and an authenticated network server:

{
  "lmStudio.instances": [
    {
      "name": "Local",
      "url": "http://127.0.0.1:1234"
    },
    {
      "name": "Workstation",
      "url": "http://192.168.1.12:1234",
      "apiKey": "<your-lm-studio-api-token>"
    }
  ]
}

With multiple instances, model names include the instance suffix: <model-key>/Workstation. With one instance, the suffix is hidden. Give instances distinct names so you can tell their models apart.

Keep tokens in user settings, outside committed project configuration. VS Code stores these values in settings files. For a network-accessible server, enable authentication and restrict network access appropriately.

Settings reference

Open VS Code Settings and search for lmStudio, or edit User Settings JSON. Omitted properties use their defaults.

Provider settings

Setting Default What it controls
lmStudio.instances Local server at http://127.0.0.1:1234 Server connections. See the instance fields below.
lmStudio.autoLoad true Load an unloaded model when its first request arrives. With false, load the model yourself in LM Studio.
lmStudio.modelRefreshIntervalSeconds 60 Refresh the model list at this interval after the previous refresh finishes. 0 disables periodic refresh; manual and configuration-triggered refresh still work.
lmStudio.unloadPreviousModelOnSwitch true Before using a different model, unload other loaded chat models on that instance. Useful when memory is limited; also affects other applications sharing that server.
lmStudio.loadTimeoutMs 120000 Maximum wait for a model to become ready. Minimum: 1000 ms.
lmStudio.requestTimeoutMs 120000 Timeout for discovery, loading API calls, and other non-streaming requests. Minimum: 1000 ms.
lmStudio.inferenceIdleTimeoutMs 600000 Maximum wait without incoming inference data. Resets on each stream chunk; 0 disables this timeout.
lmStudio.showReasoning true Enables reasoning by default when supported. With false, requests no reasoning by default when the model allows it. A per-model selection can override this default.
lmStudio.reasoningEffort "medium" Default effort: minimal, low, medium, high, or xhigh. Effective choices depend on the model.

Times are in milliseconds, except modelRefreshIntervalSeconds. For example, 120000 ms is 2 minutes and 600000 ms is 10 minutes. A stream that keeps receiving data can run longer than the idle timeout; VS Code cancellation still stops inference.

Fields for each instance

These properties belong inside an object in the lmStudio.instances array.

Field Required Default / behavior
name Yes Display label for the server, such as Local or Workstation.
url Yes Server root URL, such as http://127.0.0.1:1234.
apiKey No Omit when authentication is not required. Otherwise, supply the server's API token.
maxOutputTokens No 8192. Response token budget, including reasoning when generated. Minimum: 1; bounded by the available context.
family No Override the family advertised to VS Code. Normally derived from the model's architecture or key. Does not change the model's capabilities.
version No Override the version advertised to VS Code. Otherwise uses the model's quantization metadata, or "1" when unavailable.

Example: one loaded model per server

To release memory when switching models and allow more time for a slow model load:

{
  "lmStudio.instances": [
    {
      "name": "Local",
      "url": "http://127.0.0.1:1234"
    }
  ],
  "lmStudio.autoLoad": true,
  "lmStudio.unloadPreviousModelOnSwitch": true,
  "lmStudio.loadTimeoutMs": 240000,
  "lmStudio.reasoningEffort": "medium"
}

Exclusive switching is enabled by default and applies per server. It can unload models used by other clients; set lmStudio.unloadPreviousModelOnSwitch to false on shared servers where that behavior is not appropriate.

Reasoning, tools, and images

Reasoning. Supported models expose a Reasoning effort selector in the model picker. That selection is persisted by VS Code and takes precedence over the global default. Some models offer an off/none choice; others support only specific effort levels. Changing effort starts a fresh request with the full history to avoid reusing an incompatible reasoning state.

When VS Code exposes the native thinking API, reasoning appears in its thinking UI. Otherwise, the provider displays a Markdown reasoning block. On builds where this API requires explicit enablement, launch VS Code with:

code --enable-proposed-api MikhailKashin.lms-copilot-provider

Tools. In Agent mode, Copilot supplies tools and manages their execution and approvals. The provider forwards tool definitions to LM Studio and supports streamed tool calls. A model that repeatedly answers with prose instead of taking an action may need a different effort level or a more capable tool-use model.

Images. Image input is available when LM Studio reports vision support. Attach an image through Copilot Chat's normal controls. A text-only model will not gain vision support through a settings override.

Context and conversation compaction

Set the model's context size in LM Studio. The extension uses the loaded context reported by the server and does not change it when loading a model. If you change the server's context configuration, reload the model in LM Studio as needed and run LM Studio: Refresh Models.

The usable prompt budget reserves room for the response. With the default output budget:

100,096 loaded context tokens − 8,192 response tokens = 91,904 input tokens

For an unloaded or context-unknown model, the provisional bootstrap context is capped at 65,536 tokens (or a smaller reported maximum). The theoretical maximum remains explanatory metadata; actual loaded capacity replaces the provisional cap when reported. After a completed response, the model tooltip shows actual last-request input, output, and reasoning usage when reported by LM Studio. Local token counts used before inference are estimates.

Copilot decides when to compact a conversation. It can summarize history automatically near its threshold, or you can request /compact in a Copilot chat that supports the command. The provider accepts the full history used for summarization, including historical thinking parts, and preserves visible messages and tool results.

Agent Host compatibility: VS Code's Agent Host BYOK bridge can restore a stored tool response and discard the preceding history, even after Copilot has compacted it. For requests identified by that bridge's conversation metadata, the provider withholds response markers and sends the SDK's full current history through the modern Responses API. Ordinary native callers retain history-bound stateful continuation. Reload Window after upgrading to clear pending bridge continuations. Existing semantic checkpoints are preserved.

Indicator after background compaction: Copilot 0.73.0 can finish a background checkpoint after the final answer without refreshing the built-in context indicator. The displayed percentage can therefore describe the last foreground request. A checkpoint's local post-compaction estimate and the summarizer's input usage are different from measured foreground usage. The next normal response reports the new actual input size; the provider does not replace this with an estimated percentage. Static system instructions and tool definitions remain after history compaction.

Output budget compatibility: leave maxOutputTokens at its default unless you need an override. Copilot builds covered by this project's investigation reserve 8,192 tokens for extension-model responses even when a different budget is configured. The provider sends your configured budget, within context limits, and identifies the accounting mismatch in the tooltip. See the context-compaction investigation for version-specific evidence and validation limits.

Before each inference attempt, the provider reserves output against actual loaded context. An otherwise rejected complete stateless text/tool request gets a bounded, authenticated LM Studio tokenizer preflight, including the model prompt template and all supported tool schemas. Verified admission reserves an additional 256 tokens for configuration/framing differences. The preflight uses a short-lived worker with a five-second deadline; cancellation and timeout await worker termination so a stalled SDK connection cannot hold the instance queue. String root parameter descriptions and comments ($comment) are relocated into the function description before both inference and counting, preserving every constraint and the original caller objects. Other unsupported root constraints remain fail-closed. Refusal errors include a content-free tokenizer failure category (such as unsupported-schema, transport-unavailable or deadline). Unsupported schemas, images, incomplete or stored hidden history and unavailable tokenization retain conservative refusal. No history or tools are silently dropped. Local component estimates and model-tokenized counts are logged separately; foreground usage still comes from actual inference.

Local and server-reported capacity refusals are errors, not assistant replies or zero-token successful turns. Copilot owns automatic and mandatory compaction scheduling. For Agent Host requests, a failed summary also blocks later foreground inference for that conversation/model, including stale SDK retries; a successful summary retry releases the scope. Retry /compact or start a new conversation after a genuine summary failure. Static system instructions and tool definitions cannot be compressed away. The tokenizer SDK and third-party license notices are bundled; no separate SDK installation is required.

Copilot summary-only compaction requests use a separate stateless, reasoning-free transaction with tools unavailable. The provider recognizes the verified SDK summary-only footer because native VS Code tool modes do not preserve tool_choice=none. It retains visible history but omits unavailable tool schemas, buffers output until successful completion and rejects diagnostic/partial/tool responses. A compaction failure must remain an error rather than replace history with an error message. This version-specific recognition is covered by actual tool-enabled SDK automatic/manual compaction tests. Previously corrupted checkpoints are not automatically repaired; preserve the old session and continue in a fresh chat with the existing project files when necessary.

Troubleshooting

Start with View → Output → LM Studio Provider. Logs identify the affected instance and endpoint. Check the LM Studio server logs for inference and model-loading errors.

Symptom What to check
No models under LM Studio Confirm the extension is enabled and the server is running. Check the root URL and token, run LM Studio: Refresh Models, and reload VS Code after an extension update.
Connection works locally but not from another computer Enable Serve on Local Network, use the server computer's LAN address, and check its firewall and port. 127.0.0.1 always refers to the computer making the request.
HTTP 401/403 Verify the server's authentication settings and the instance's apiKey. Use the token value without Bearer.
HTTP 404 or invalid model-list response Remove endpoint suffixes from url and check that the LM Studio version exposes /api/v1/models and /v1/responses.
A model is listed but will not load Check available RAM/VRAM and LM Studio's load error. If autoLoad is false, load it manually. Increase loadTimeoutMs if the load is progressing slowly.
A removed/offline server's models remain listed Last-known models are retained when discovery fails temporarily. Check the instance's reachability before retrying inference.
No Agent tools or image input Check the selected model's advertised capabilities in the tooltip. Refresh discovery after changing models or server configuration.
Long thinking with little or no final answer Try a lower reasoning effort or an off choice if supported. Reasoning shares the response budget.
Context overflow or compaction failure Check the actual loaded context, install the latest provider build, reload VS Code, and refresh models. Try /compact if available; if summarization cannot fit, start a shorter chat or load a larger context in LM Studio.
unknown streaming error after installing a candidate Check the active path in Output → LM Studio Provider. A local candidate can have the same version as the final release. Reinstall the official VSIX with code --install-extension <file.vsix> --force, then reload the VS Code window. Installed qualification compares production SHA-256 hashes and runtime manifest fields, not only the version.
A fresh agent chat exceeds context System instructions and tool schemas also consume input. /compact cannot shrink static instructions/tools. Check the actual loaded context; deliberately choose a larger server context or reduce enabled tools. The provider preserves your server context and tool inventory.
Inference stalls Check the server logs and network. Adjust inferenceIdleTimeoutMs if long pauses during prompt processing are expected.

Development and verification

npm ci
npm run check
npm test
npm run test:compaction

test:compaction runs a real VS Code Extension Host and the pinned Copilot runtime against a deterministic LM Studio HTTP fixture. It checks automatic threshold compaction, the manual compaction RPC, history reduction, thinking replay, and retained requirements. Test settings, extensions, and Copilot state are isolated under .vscode-test/. Set VSCODE_EXECUTABLE_PATH for a non-default VS Code installation.

For an optional live-model summary and continuation check:

npm run test:compaction -- --live

The live check reads the mind instance from VS Code user settings and selects qwen3.8-27b@iq3_xxs by default. Override these with LMS_TEST_INSTANCE, LMS_TEST_MODEL, and LMS_TEST_SETTINGS_PATH. It does not change loaded context or enable exclusive unloading. Physical context exhaustion on every live model is not covered by this smoke test.

For packaged-extension checks, install the VSIX into .vscode-test/compaction-extensions using a separate .vscode-test/compaction-installed-user user-data directory, then run npm run test:compaction -- --installed (optionally add --live). The test verifies the installed path/version, runtime manifest fields and SHA-256 of every production JavaScript file against the intended source build. It also verifies nested server context errors, failed-tool suppression and bounded reasoning-free malformed-tool recovery. The live variant additionally checks a required diagnostic tool call without executing it.

See CHANGELOG.md for releases and the compaction report for investigation evidence. Report problems through GitHub Issues, including provider/VS Code/LM Studio versions and relevant logs with API tokens removed.

Development follows the issue, branch, pull request and OpenSpec lifecycle in AGENTS.md. Install Node.js 24, run npm ci, and include npm run check:specs with the code checks above. Unpublished changes accumulate in CHANGELOG.md; a merge does not publish a release.

Native output-format parser errors on tool-enabled ordinary requests receive one modern retry without reasoning before visible text. Failed buffered tools are suppressed. Repeated failure remains an error. XML text inside a valid string tool argument is preserved as data and never interpreted as an additional tool call.

If an existing Copilot chat keeps using the previous model after a switch, see the explicit Agent Host compatibility repair. The affected host ignores a required-compaction result; a VSIX alone cannot repair that earlier selection step. The opt-in tool preserves an original backup and verifies actual selection before continuation.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft