How to Use a Local AI Model in VS Code with Cline A guide checked on 30 November 2026 against Cline 4.1.28 documents how to run an AI coding agent inside VS Code with a model hosted locally through Ollama or LM Studio, avoiding per-token bills and sending prompts to a cloud provider. The guide recommends setting Cline's Model Context Window to 32768 by default (65536 with spare memory) because Cline sends that value to Ollama, and warns that Cline 4.1.28 approves file edits automatically by default while asking before executing commands. It also notes the "Use Compact Prompt" option described in Cline's documentation and many tutorials is gone from the 4.1.28 code, and advises avoiding Ollama tags ending in -cloud, which run on Ollama's servers rather than the user's machine. 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: 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 https://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: 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: 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: 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: 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 https://lmstudio.ai and download a model in the Discover tab. 2. Load it with a larger context window: lms ls lms load