{"schemaVersion":"1.0","type":"TechArticle","types":["Article","TechArticle"],"slug":"how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk","url":"https://zyvop.com/how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk","title":"How to Use a Local AI Model in VS Code with Cline","subtitle":"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.","tldr":"Want an AI coding agent with the model on your own computer? This guide sets up Cline in VS Code with Ollama or LM Studio, covers model choices and the context window, and shows the default setting that lets Cline edit files without asking.","keywords":["Cline","local-ai","ollama","AI Coding Agents","VS Code","Developer Tools"],"entities":["Bhavya Arora","Cline","local-ai","ollama","AI Coding Agents","VS Code","Developer Tools","ZyVOP"],"keyTakeaways":["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."],"headings":["What you need","Step 1: Install Cline","Step 2: Install Ollama and download a model","Step 3: Connect Cline to Ollama","Step 4: Set the context window","What about \"Use Compact Prompt\"?","Step 5: Check auto-approve before your first task","Step 6: Run your first task","Using LM Studio instead","Is your code really private?","Troubleshooting","Is a local model good enough?","FAQ","Final checklist","Sources"],"outboundLinks":["https://ollama.com/","https://lmstudio.ai/","https://docs.cline.bot/running-models-locally/overview","https://github.com/cline/cline/blob/v4.1.28/apps/vscode/webview-ui/src/components/settings/providers/OllamaProvider.tsx","https://github.com/cline/cline/blob/v4.1.28/sdk/packages/llms/src/providers/vendors/ollama.ts","https://github.com/cline/cline/blob/v4.1.28/apps/vscode/src/shared/AutoApprovalSettings.ts","https://github.com/cline/cline/blob/v4.1.28/apps/vscode/src/sdk/sdk-tool-policies.ts","https://github.com/cline/cline/blob/v4.1.28/apps/vscode/proto/cline/state.proto","https://docs.ollama.com/integrations/cline","https://docs.ollama.com/context-length","https://docs.ollama.com/faq","https://ollama.com/library/ornith-1.5/tags","https://ollama.com/library/gpt-oss:20b","https://ollama.com/library/qwen3.8","https://lmstudio.ai/docs/cli/load"],"contentText":"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-devIf 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: ollama pull ornith-1.5:9b ollama run ornith-1.5:9bType 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 Open the Cline panel and go to Settings, then API Configuration. Set API Provider to Ollama. Leave Use custom base URL unticked. The default is http://localhost:11434. Choose your model in the Model field. 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 psThe 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 Install LM Studio and download a model in the Discover tab. Load it with a larger context window: lms ls lms load &lt;model_key&gt; --context-length 32768 lms server startIn 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 Install Cline and Ollama. Pull a model that fits your memory. Select Ollama in Cline. Set the context window in Cline. Check auto-approve. 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","contentHash":"sha256:374b5a900f1397c913695e539a249eb2b3dbe00d9a5d49ba0e37aaaa9688a40c","authorName":"Bhavya Arora","authorUrl":"https://zyvop.com/author/bhavya","authorSameAs":[],"category":"Developer Tools","tags":["Cline","local-ai","ollama","AI Coding Agents","VS Code"],"audience":"Software engineers and developers building applications with Developer Tools","tone":"Instructional, practical, code-first","readingTimeMinutes":6,"wordCount":1375,"faqs":[{"question":"Is this free?","answer":"Cline's extension and running models locally have no usage fee. You still pay for hardware and electricity."},{"question":"Do I need a GPU?","answer":"Not strictly, but without one it can be too slow for agent work."},{"question":"Can the model run on another machine?","answer":"Yes. Tick Use custom base URL and enter that machine's address. Only do this on a network you trust."},{"question":"Is there an easier setup?","answer":"Cline also makes a separate desktop app. Its documentation says the Local Models page can recommend, download and set up models for your hardware."}],"primaryTopic":"Developer Tools","publishedAt":"2026-11-30T09:55:49.413Z","updatedAt":"2026-11-30T09:55:49.413Z","canonicalUrl":"https://zyvop.com/how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk"}