--- title: "How to Use a Local AI Model in VS Code with Cline" author: "Bhavya Arora" published: "2026-11-30T09:55:49.413Z" updated: "2026-11-30T09:55:49.413Z" url: "https://zyvop.com/how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk" canonical: "https://zyvop.com/how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk" tags: ["Cline","local-ai","ollama","AI Coding Agents","VS Code"] --- # How to Use a Local AI Model in VS Code with Cline Run Cline in VS Code with Ollama or LM Studio: pick a model, set the context window and check auto-approve before your first task. ![Cover image]() You can run an AI coding agent in VS Code with the model on your own computer. There is no per-token bill, and your prompts do not need to go to a cloud model provider. This guide uses **Cline**, an open-source coding agent, with **Ollama**. LM Studio is covered too. > Checked on 30 November 2026 against Cline 4.1.28 (documentation and source code) and the Ollama and LM Studio pages. This guide is not a hands-on performance test. Menus and defaults can change. ## What you need - VS Code 1.101 or newer - The Cline extension - Ollama or LM Studio - Enough memory for the model you choose - A project under Git, so you can undo changes Cline's documentation gives this rough hardware guide: | RAM | What to expect | | --- | --- | | 16 to 32 GB | Small or quantized models | | 32 to 64 GB | Mid-size coding models | | 64 GB or more | Larger models and longer context | A graphics card or Apple Silicon makes a big difference to speed. On a PC with a graphics card, the model and its context should ideally fit in the card's memory (VRAM), not just in RAM. A model can run on the CPU alone, but expect it to be slow. ## Step 1: Install Cline Open the Extensions view (`Ctrl+Shift+X`, or `Cmd+Shift+X` on Mac), search for **Cline** and click **Install**. Or use the terminal: ```bash code --install-extension saoudrizwan.claude-dev ``` If Cline asks how you want to use it, pick the **bring your own API key** option. You do not need an API key or a Cline account for a local model. ## Step 2: Install Ollama and download a model Install Ollama from [ollama.com](), then pick a model that fits your computer. | Your memory | Model to try | Download size | | --- | --- | --- | | 16 GB | `ornith-1.5:9b` | 6.6 GB | | 24 GB (16 GB is tight) | `gpt-oss:20b` | 14 GB | | 32 GB or more | `qwen3.8:27b` | 18 GB | These are starting points based on size and each model's description, not on testing. **Download size is not the memory you need.** The context window uses extra memory on top. Download one and check that it answers: ```bash ollama pull ornith-1.5:9b ollama run ornith-1.5:9b ``` Type a short question. Type `/bye` to exit. **Avoid tags ending in** `-cloud`**.** Those run on Ollama's servers, not on your computer. ## Step 3: Connect Cline to Ollama 1. Open the Cline panel and go to **Settings**, then **API Configuration**. 2. Set **API Provider** to **Ollama**. 3. Leave **Use custom base URL** unticked. The default is `http://localhost:11434`. 4. Choose your model in the **Model** field. 5. Check **Model Context Window**. ## Step 4: Set the context window This is the setting that is easy to get wrong. The context window is how much text the model can work with at once: instructions, your messages, file contents and command output. Cline sends its **Model Context Window** value to Ollama with its requests. So set it **in Cline**. Changing only the context slider in Ollama's app will not change what Cline asks for. - Cline's default is **32768**. - Ollama's Cline guide says to use at least 32K for coding. - Ollama's general advice for agents and coding tools is at least 64,000. Start at 32768. If you have memory to spare, try 65536. After sending a message, run: ```bash ollama ps ``` The `CONTEXT` column shows the size in use. The `PROCESSOR` column ideally says `100% GPU`. If it shows a CPU/GPU split, use a smaller model or a smaller context. ### What about "Use Compact Prompt"? Cline's documentation and many tutorials tell you to turn on **Use Compact Prompt** under Settings, then Features. **In version 4.1.28 that option is gone from the code.** If you cannot find it, you have not missed a step. ## Step 5: Check auto-approve before your first task **Do not assume Cline will ask before changing files.** In the 4.1.28 source code, the default settings are: | Action | Default | | --- | --- | | Read files | Approved automatically | | Edit files | **Approved automatically** | | Execute commands | Asks you | | Fetch web content | Approved automatically | | Use MCP servers | Approved automatically | Click the **Auto-approve** bar in the Cline panel. To review changes first, switch off **Edit files**. For private work, also switch off **Fetch web content** and **Use MCP servers**. Your settings may differ if you changed them earlier or your organisation controls them. ## Step 6: Run your first task Commit your current work first. Then switch to **Plan** mode and try: ```text Explain how this project is organised. Then tell me which files you would change to add input validation to the signup form. Do not edit anything. ``` Plan mode turns off the file editor and is designed to block commands that edit files. It can still run commands to inspect the project, and with default settings it asks you first. Happy with the plan? Switch to **Act** mode and give it one small step: ```text Add validation for the email field only. Show me what you changed. ``` Read the diff and run your tests before you commit. ## Using LM Studio instead 1. Install [LM Studio]() and download a model in the **Discover** tab. 2. Load it with a larger context window: ```bash lms ls lms load --context-length 32768 lms server start ``` 1. In Cline, set **API Provider** to **LM Studio** and choose the model. The default address is `http://localhost:1234`. In Cline, the LM Studio **Context Window** box is read-only. Change the value in LM Studio, not in Cline. You only need an API key in Cline if you turned on **Require Authentication** in LM Studio. ## Is your code really private? Running the model locally is a big step, but check the rest too: - **The model:** Ollama says it does not see your prompts or data when you run locally. - **Cloud features:** to turn off Ollama's cloud features, set `OLLAMA_NO_CLOUD=1` and restart Ollama. - **Tools:** web fetching, MCP servers and terminal commands can send data off your computer. - **Cline reporting:** in Cline's General settings, **Allow error and usage reporting** is on unless you turn it off. - **Mixed models:** if you use a cloud model for Plan or Act mode, your task content goes to that provider. For client or company code, confirm what your policy allows. ## Troubleshooting | Problem | What to try | | --- | --- | | Cline cannot list your models | Check that Ollama is running. Open `http://localhost:11434` in a browser, then run `ollama list`. | | First reply takes very long or times out | The model has to load first. Raise **Request Timeout (ms)**; the default is 300000 (5 minutes). | | Every reply is slow | Run `ollama ps`. Try a smaller model or context window. | | Out of memory | Lower the context window or use a smaller model. | | It forgets instructions or loses the thread | Start a new task, keep it smaller, or raise the context window. | | Edits or tool use keep failing | Break the task into smaller steps or try another model with tool support. | ## Is a local model good enough? It depends on your hardware and the job. Cline's own settings screen warns that less capable models may not work as expected. A sensible split: - **Try local for:** explaining code, small fixes, tests, boilerplate and private experiments. - **Consider a cloud model for:** large refactors, hard debugging and changes across many files. Test with a real task from your project before relying on it. ## FAQ **Is this free?** Cline's extension and running models locally have no usage fee. You still pay for hardware and electricity. **Do I need a GPU?** Not strictly, but without one it can be too slow for agent work. **Can the model run on another machine?** Yes. Tick **Use custom base URL** and enter that machine's address. Only do this on a network you trust. **Is there an easier setup?** Cline also makes a separate desktop app. Its documentation says the Local Models page can recommend, download and set up models for your hardware. ## Final checklist 1. Install Cline and Ollama. 2. Pull a model that fits your memory. 3. Select Ollama in Cline. 4. Set the context window in Cline. 5. Check auto-approve. 6. Commit, plan, then act. * * * ## Sources **Cline** - [Local models]() - Source code, version 4.1.28: [Ollama settings](), [Ollama requests](), [auto-approve defaults](), [approval checks](), [removed compact prompt setting]() **Ollama** - [Cline integration](), [context length](), [FAQ]() - Models: [ornith-1.5](), [gpt-oss:20b](), [qwen3.8]() **LM Studio** - [Loading a model from the command line]()