For some work — confidential code, air-gapped environments, or simply not wanting your code on anyone’s server — a fully self-hosted coding agent is the answer. Run a model locally, connect the Cline extension in VS Code, and you have an in-editor AI agent that never sends a byte off your machine and costs nothing per token. This is how to build it on Windows.
For the cloud equivalent (cheaper to get good quality), see DeepSeek + Cline in VS Code.
The pieces
A self-hosted agent stack
| Local server | Ollama or LM Studio hosts the model |
|---|---|
| Model | A coding model that fits your hardware |
| Agent UI | Cline (VS Code) via OpenAI Compatible provider |
| Cost | None per token — hardware + electricity only |
Step 1: Host a local model
Pick a host:
- Ollama — CLI-friendly;
ollama pulla model and it serves onhttp://localhost:11434/v1. See DeepSeek locally with Ollama. - LM Studio — GUI app; download a model and start its server on
http://localhost:1234/v1. See Qwen3-Coder with LM Studio.
Choose a coding-focused model that fits your hardware — a quantized Qwen3-Coder, a DeepSeek distill, or GLM-4.5-Air.
Step 2: Install Cline in VS Code
Install VS Code and the Cline extension from the marketplace. Cline runs on native Windows — no WSL required — and gives you an in-editor agent with plan-and-approve.
Step 3: Point Cline at your local server
In Cline’s settings, choose OpenAI Compatible and set the local endpoint:
Cline settings for a local model
| API Provider | OpenAI Compatible |
|---|---|
| Base URL | http://localhost:11434/v1 (Ollama) or :1234/v1 (LM Studio) |
| API Key | any value (e.g. local) |
| Model ID | your local model's name |
Save, and Cline runs entirely on your local model. Use Plan mode to keep the smaller model focused.
The honest trade-offs
A self-hosted agent wins decisively on privacy (nothing leaves your machine) and cost (no API bill). It loses on capability and speed: a model that fits consumer hardware is smaller than the top hosted models, so it’s weaker on hard tasks and slower than a cloud endpoint. That’s the deal — and for sensitive or offline work, it’s a deal worth taking.
When self-hosting is the right call
- Confidential or regulated code that can’t go to a third party.
- Air-gapped or offline environments.
- Zero-API-cost requirements.
- Learning and experimentation without bills.
If none of those apply, a cheap cloud model gives better results for very little money.
Troubleshooting
- Cline can’t connect — the local server isn’t running, or the port is wrong.
- Slow / out of memory — model too big; use a smaller quantization.
- Weak results — expected for small local models; reserve hard tasks for cloud.
- Model ID rejected — use the exact name your host reports.
Self-hosted agent checklist
- Local server running (Ollama or LM Studio)
- A coding model that fits your hardware loaded
- Cline installed in VS Code
- OpenAI Compatible provider pointed at the local URL
- Plan mode used; hard tasks optionally sent to cloud
Wrapping up
A self-hosted coding agent on Windows is Cline plus a local model from Ollama or LM Studio: point Cline’s OpenAI Compatible provider at your local server and you have a private, zero-API-cost agent in VS Code. The honest trade-off is capability — local models are smaller — so it’s ideal for confidential, offline, or no-cost work, with a cheap cloud model in reserve for the hardest tasks.
For the local hosts, see DeepSeek with Ollama and Qwen3-Coder with LM Studio.