{"slug": "how-to-use-a-local-ai-model-in-vs-code-with-cline", "title": "How to Use a Local AI Model in VS Code with Cline", "summary": "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.", "body_md": "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.\n\nThis guide uses **Cline**, an open-source coding agent, with **Ollama**. LM Studio is covered too.\n\nChecked 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.\n\n## What you need\n\n- VS Code 1.101 or newer\n- The Cline extension\n- Ollama or LM Studio\n- Enough memory for the model you choose\n- A project under Git, so you can undo changes\n\nCline's documentation gives this rough hardware guide:\n\n| RAM | What to expect | \n|---|---|\n| 16 to 32 GB | Small or quantized models | \n| 32 to 64 GB | Mid-size coding models | \n| 64 GB or more | Larger models and longer context | \n\nA 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.\n\n## Step 1: Install Cline\n\nOpen the Extensions view (`Ctrl+Shift+X`, or `Cmd+Shift+X` on Mac), search for **Cline** and click **Install**. Or use the terminal:\n\n```\ncode --install-extension saoudrizwan.claude-dev\n```\n\nIf 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.\n\n## Step 2: Install Ollama and download a model\n\nInstall Ollama from [ollama.com](https://ollama.com), then pick a model that fits your computer.\n\n| Your memory | Model to try | Download size | \n|---|---|---|\n| 16 GB | `ornith-1.5:9b` | 6.6 GB | \n| 24 GB (16 GB is tight) | `gpt-oss:20b` | 14 GB | \n| 32 GB or more | `qwen3.8:27b` | 18 GB | \n\nThese 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.\n\nDownload one and check that it answers:\n\n```\nollama pull ornith-1.5:9b\nollama run ornith-1.5:9b\n```\n\nType a short question. Type `/bye` to exit.\n\n**Avoid tags ending in** `-cloud`**.** Those run on Ollama's servers, not on your computer.\n\n## Step 3: Connect Cline to Ollama\n\n1. Open the Cline panel and go to **Settings** , then**API Configuration** .\n2. Set **API Provider** to**Ollama** .\n3. Leave **Use custom base URL** unticked. The default is`http://localhost:11434` .\n4. Choose your model in the **Model** field.\n5. Check **Model Context Window** .\n\n## Step 4: Set the context window\n\nThis 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.\n\nCline 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.\n\n- Cline's default is **32768** .\n- Ollama's Cline guide says to use at least 32K for coding.\n- Ollama's general advice for agents and coding tools is at least 64,000.\n\nStart at 32768. If you have memory to spare, try 65536. After sending a message, run:\n\n```\nollama ps\n```\n\nThe `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.\n\n### What about \"Use Compact Prompt\"?\n\nCline'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.\n\n## Step 5: Check auto-approve before your first task\n\n**Do not assume Cline will ask before changing files.** In the 4.1.28 source code, the default settings are:\n\n| Action | Default | \n|---|---|\n| Read files | Approved automatically | \n| Edit files | **Approved automatically** | \n| Execute commands | Asks you | \n| Fetch web content | Approved automatically | \n| Use MCP servers | Approved automatically | \n\nClick 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**.\n\nYour settings may differ if you changed them earlier or your organisation controls them.\n\n## Step 6: Run your first task\n\nCommit your current work first. Then switch to **Plan** mode and try:\n\n```\nExplain how this project is organised. Then tell me which files you\nwould change to add input validation to the signup form. Do not edit anything.\n```\n\nPlan 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.\n\nHappy with the plan? Switch to **Act** mode and give it one small step:\n\n```\nAdd validation for the email field only. Show me what you changed.\n```\n\nRead the diff and run your tests before you commit.\n\n## Using LM Studio instead\n\n1. Install [LM Studio](https://lmstudio.ai) and download a model in the**Discover** tab.\n2. Load it with a larger context window:\n\n```\nlms ls\nlms load <model_key> --context-length 32768\nlms server start\n```\n\n1. In Cline, set **API Provider** to**LM Studio** and choose the model. The default address is`http://localhost:1234` .\n\nIn 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.\n\n## Is your code really private?\n\nRunning the model locally is a big step, but check the rest too:\n\n- **The model:** Ollama says it does not see your prompts or data when you run locally.\n- **Cloud features:** to turn off Ollama's cloud features, set`OLLAMA_NO_CLOUD=1` and restart Ollama.\n- **Tools:** web fetching, MCP servers and terminal commands can send data off your computer.\n- **Cline reporting:** in Cline's General settings,**Allow error and usage reporting** is on unless you turn it off.\n- **Mixed models:** if you use a cloud model for Plan or Act mode, your task content goes to that provider.\n\nFor client or company code, confirm what your policy allows.\n\n## Troubleshooting\n\n| Problem | What to try | \n|---|---|\n| Cline cannot list your models | Check that Ollama is running. Open `http://localhost:11434` in a browser, then run`ollama list` . | \n| First reply takes very long or times out | The model has to load first. Raise **Request Timeout (ms)** ; the default is 300000 (5 minutes). | \n| Every reply is slow | Run `ollama ps` . Try a smaller model or context window. | \n| Out of memory | Lower the context window or use a smaller model. | \n| It forgets instructions or loses the thread | Start a new task, keep it smaller, or raise the context window. | \n| Edits or tool use keep failing | Break the task into smaller steps or try another model with tool support. | \n\n## Is a local model good enough?\n\nIt depends on your hardware and the job. Cline's own settings screen warns that less capable models may not work as expected.\n\nA sensible split:\n\n- **Try local for:** explaining code, small fixes, tests, boilerplate and private experiments.\n- **Consider a cloud model for:** large refactors, hard debugging and changes across many files.\n\nTest with a real task from your project before relying on it.\n\n## FAQ\n\n**Is this free?**\nCline's extension and running models locally have no usage fee. You still pay for hardware and electricity.\n\n**Do I need a GPU?**\nNot strictly, but without one it can be too slow for agent work.\n\n**Can the model run on another machine?**\nYes. Tick **Use custom base URL** and enter that machine's address. Only do this on a network you trust.\n\n**Is there an easier setup?**\nCline also makes a separate desktop app. Its documentation says the Local Models page can recommend, download and set up models for your hardware.\n\n## Final checklist\n\n1. Install Cline and Ollama.\n2. Pull a model that fits your memory.\n3. Select Ollama in Cline.\n4. Set the context window in Cline.\n5. Check auto-approve.\n6. Commit, plan, then act.\n\n## Sources\n\n**Cline**\n\n- [Local models](https://docs.cline.bot/running-models-locally/overview)\n- Source code, version 4.1.28: [Ollama settings](https://github.com/cline/cline/blob/v4.1.28/apps/vscode/webview-ui/src/components/settings/providers/OllamaProvider.tsx) ,[Ollama requests](https://github.com/cline/cline/blob/v4.1.28/sdk/packages/llms/src/providers/vendors/ollama.ts) ,[auto-approve defaults](https://github.com/cline/cline/blob/v4.1.28/apps/vscode/src/shared/AutoApprovalSettings.ts) ,[approval checks](https://github.com/cline/cline/blob/v4.1.28/apps/vscode/src/sdk/sdk-tool-policies.ts) ,[removed compact prompt setting](https://github.com/cline/cline/blob/v4.1.28/apps/vscode/proto/cline/state.proto)\n\n**Ollama**\n\n- [Cline integration](https://docs.ollama.com/integrations/cline) ,[context length](https://docs.ollama.com/context-length) ,[FAQ](https://docs.ollama.com/faq)\n- Models: [ornith-1.5](https://ollama.com/library/ornith-1.5/tags) ,[gpt-oss:20b](https://ollama.com/library/gpt-oss:20b) ,[qwen3.8](https://ollama.com/library/qwen3.8)\n\n**LM Studio**", "url": "https://wpnews.pro/news/how-to-use-a-local-ai-model-in-vs-code-with-cline", "canonical_source": "https://zyvop.com/how-to-use-a-local-ai-model-in-vs-code-with-cline-cicsk", "published_at": "2026-11-30 09:55:49+00:00", "updated_at": "2026-11-30 10:15:29.753800+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "large-language-models", "ai-products"], "entities": ["Cline", "Ollama", "LM Studio", "Visual Studio Code", "ornith-1.5:9b", "gpt-oss:20b", "qwen3.8:27b"], "also_reported_by": [], "takeaway": "Set the context window in Cline, not Ollama's app, starting at 32768 and trying 65536 with spare memory, then confirm with `ollama ps` that the CONTEXT column matches and PROCESSOR reads 100% GPU.", "recommendation": {"advice": "Set Cline's Model Context Window to 32768 (65536 with spare memory) since Cline sends that value to Ollama, verify with `ollama ps`, and check auto-approve settings because 4.1.28 approves file edits by default.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/how-to-use-a-local-ai-model-in-vs-code-with-cline", "markdown": "https://wpnews.pro/news/how-to-use-a-local-ai-model-in-vs-code-with-cline.md", "text": "https://wpnews.pro/news/how-to-use-a-local-ai-model-in-vs-code-with-cline.txt", "jsonld": "https://wpnews.pro/news/how-to-use-a-local-ai-model-in-vs-code-with-cline.jsonld"}}