How to use LM Studio in VS Code with Kingcurve
Kingcurve connects Visual Studio Code to the models you run in LM Studio. You get chat about your code, multi-file edits shown as diffs you approve, and a coding agent, all on your own hardware. It is free and MIT-licensed, and Kingcurve has no server of its own.
1. Start the LM Studio server
- Install LM Studio and download a model, for example a Qwen2.5 Coder model.
- Open the Developer tab and start the server (port 1234 by default), or run
lms server start.
2. Context length: automatic
LM Studio sets the context length when it loads a model, and the default is often only 4,096 tokens. That is enough for short chats, but too small for Agent mode: the descriptions of the agent's tools alone take about 2,100 tokens.
Kingcurve handles this for you. When a conversation or Agent mode needs more than the loaded context, Kingcurve reloads the model with a larger context through LM Studio's REST API: 8K, 16K or 32K, up to Settings → Maximum automatic context (32K by default) and the model's maximum. The message box shows "Reloading … with a larger context" while this happens. If the larger context does not fit in memory, Kingcurve loads the model again with its previous context.
This needs LM Studio 0.4 or newer, which has the REST API v1. With older versions, load the model with a Context Length of 16,384 to 32,768 yourself. To keep a fixed context, turn off Adjust context length automatically in Kingcurve's Settings.
3. Install and connect Kingcurve
- Install Kingcurve from the Visual Studio Marketplace (VS Code 1.106 or newer).
- Open it with
Cmd+Alt+M(macOS) orCtrl+Alt+M(Windows, Linux). It opens in the Secondary Side Bar on the right. - Kingcurve finds LM Studio at
http://127.0.0.1:1234/v1automatically. Click Test on the LM Studio provider, then choose a model in the message box (bottom left).
Kingcurve uses LM Studio's own API to show each model's type, whether it is loaded and its context length, and whether it supports tool use.
4. Use LM Studio on another computer
- In LM Studio, turn on Serve on Local Network.
- In Kingcurve, set the provider's Base URL to that computer, for example
http://192.168.1.42:1234/v1.
If LM Studio has Require Authentication on, you get HTTP 401 … An LM Studio API token is required. Create a token in LM Studio and paste it into the provider's API key field. LM Studio serves plain http, so also tick Allow API key over http on the local network. Kingcurve only allows this for private network addresses, and anyone on the same network could read the token. Use it only on a network you trust, or turn authentication off in LM Studio.
5. Choose a mode
- Ask: questions about your code, read-only.
- Edit: changes proposed as diffs; works with every model.
- Plan: a plan you approve before anything changes.
- Agent: reads, edits, runs commands and tests, and verifies. It needs a model with tool support.
Attach context with @, or paste a screenshot or UI mockup. Images need a vision model: in LM Studio, these are the models of type VLM.
Troubleshooting
- HTTP 401. Authentication is on; see step 4.
- "The conversation no longer fits the model context window". Raise Maximum automatic context in Kingcurve's Settings (step 2), lower Max output tokens, or start a new conversation. With LM Studio older than 0.4, reload the model with a larger context yourself.
- Images are refused. The loaded model is not a VLM. Load a vision model.
- Cannot connect. Check that the server is running in the Developer tab, and that the Base URL and port match.