How to Use a Free Local AI in VS Code with Ollama and Continue
Run an AI coding model on your own computer. Your code never leaves your machine. No account, no monthly bill. Ollama runs the model. Continue connects it to VS Code.
In short: install Ollama, run ollama pull qwen2.5-coder:7b, install the Continue extension, and point ~/.continue/config.yaml at Ollama.
Why use a local AI
Some code is private: a bank's code, client data, or code under NDA. A local model keeps it all on your laptop. It also works offline and costs nothing per request. The trade-off: small local models are slower and weaker than big cloud models.
What you need
- Ollama: a free tool that downloads and runs AI models locally. It serves them at
http://localhost:11434. - A coding model: for example
qwen2.5-coder:7bfor chat,qwen2.5-coder:1.5bfor fast autocomplete. - Continue: an open-source extension for VS Code and JetBrains that talks to Ollama.
- Hardware: at least 8 GB RAM (16 GB+ better) and about 10 GB free disk. A GPU makes it much faster.
How it connects
Install steps
- Install Ollama. Windows/Mac: download from ollama.com. Linux:
curl -fsSL https://ollama.com/install.sh | sh. - Check it:
ollama --version. - Make sure it is running:
curl http://localhost:11434should printOllama is running. If not, runollama serve. - Pull the models (use
pull, notrun):ollama pull qwen2.5-coder:7bandollama pull qwen2.5-coder:1.5b. - Check:
ollama listshows both, with the exact tags. - Install Continue: in VS Code press Ctrl+Shift+X, search Continue, install. Or:
code --install-extension Continue.continue. - Open the Continue panel from the Activity Bar.
ollama --version
curl http://localhost:11434
# -> Ollama is running
ollama pull qwen2.5-coder:7b
ollama pull qwen2.5-coder:1.5b
ollama listConfiguration: config.yaml
Open Continue's config (gear icon, or the file ~/.continue/config.yaml). The model name must match ollama list exactly.
name: Local Config
version: 0.0.1
schema: v1
models:
- name: Qwen2.5-Coder 7B
provider: ollama
model: qwen2.5-coder:7b
apiBase: http://localhost:11434
roles:
- chat
- edit
- apply
- name: Qwen2.5-Coder 1.5B
provider: ollama
model: qwen2.5-coder:1.5b
roles:
- autocompleteSettings
- After editing, click Reload config in Continue's config selector.
- Autodetect: instead of listing models, you can set
model: AUTODETECTwithprovider: ollama; Continue lists what you pulled. - “Model requires more system memory” error: add
defaultCompletionOptions: contextLength: 2048under the model, or use a smaller model. - Agent mode needs tool use. Small local models are weak at it; use chat and edit for best results.
- Another PC runs Ollama? set
apiBaseto that machine's address.
First test: a small function
Write a Python function is_palindrome(s) that ignores case and spaces. Only return the code.
A correct answer looks like this. We tested this version:
palindrome.pydef is_palindrome(s: str) -> bool:
"""True if s reads the same both ways, ignoring case and spaces."""
clean = "".join(s.lower().split())
return clean == clean[::-1]test_palindrome.pyfrom palindrome import is_palindrome
def test_yes():
assert is_palindrome("Never odd or even")
def test_no():
assert not is_palindrome("Pune")
def test_empty():
assert is_palindrome("")pytest -q
# -> 3 passedSmall models make more mistakes than big ones. Always run the test.
| Local (Ollama + Continue) | Cloud assistant | |
|---|---|---|
| Privacy | Code stays on your PC | Code goes to the provider |
| Cost | Free after download | Plan or per-token price |
| Quality | Good for small tasks | Stronger on big tasks |
| Speed | Depends on your hardware | Fast |
| Offline | Yes | No |
ollama pull from the official library, and check the exact tag.Verify your local AI: fix a small cycle rental bug with Ollama and Continue Edit
Hello friends. The chapter above showed how to install Ollama, pull a coding model and connect it to Continue. Now we prove that the whole chain works on your own computer. You will open a tiny practice folder for a fictional shop called Jasmine Cycle Rental, select one function, and ask your local model to fix it with Continue Edit. The change appears as an inline diff, and you accept or reject it. The starter file fails 4 tests and passes 3, and a correct fix passes all 7.
नमस्कार मित्रांनो. वरच्या chapter मध्ये आपण Ollama install करणं, coding model pull करणं आणि तो Continue ला जोडणं पाहिलं. आता ही पूर्ण साखळी तुमच्या स्वतःच्या computer वर चालते का ते तपासूया. Jasmine Cycle Rental नावाच्या काल्पनिक दुकानाचा एक छोटा practice folder उघडा, एक function select करा, आणि Continue Edit वापरून तुमच्या local model ला तो fix करायला सांगा. बदल inline diff म्हणून दिसतो, आणि तो accept किंवा reject तुम्ही करता. Starter file मध्ये 4 tests fail आणि 3 pass होतात, आणि बरोबर fix केल्यावर सगळे 7 pass होतात.
नमस्ते दोस्तों. ऊपर के chapter में हमने Ollama install करना, coding model pull करना और उसे Continue से जोड़ना देखा. अब देखते हैं कि यह पूरी chain आपके अपने computer पर चलती है या नहीं. Jasmine Cycle Rental नाम की काल्पनिक दुकान का एक छोटा practice folder खोलो, एक function select करो, और Continue Edit से अपने local model को उसे ठीक करने को कहो. बदलाव inline diff की तरह दिखता है, और उसे accept या reject आप करते हो. Starter file में 4 tests fail और 3 pass होते हैं, और सही fix के बाद सभी 7 pass होते हैं।
Ravindra Bagale's Tip
Small local models do best with short, exact instructions on a small piece of code. Select only the one function, give one or two clear rules with an example number, and let the tests decide whether the answer is right.
Ravindra Bagale's Tip – मराठी
छोटे local models छोट्या code वर लहान आणि नेमक्या सूचना दिल्या की चांगलं काम करतात. फक्त एकच function select करा, एक किंवा दोन स्पष्ट नियम उदाहरणाच्या आकड्यासोबत सांगा, आणि उत्तर बरोबर आहे की नाही ते tests ना ठरवू द्या.
Ravindra Bagale's Tip – हिंदी
छोटे local models छोटे code पर छोटे और सटीक निर्देशों से सबसे अच्छा काम करते हैं. सिर्फ़ एक function select करो, एक या दो साफ़ नियम एक उदाहरण वाली संख्या के साथ बताओ, और जवाब सही है या नहीं, यह tests को तय करने दो।
Python 3.13.5 and pytest 9.1.1. Starter: 4 failed, 3 passed. Fixed file: 7 passed. The AI tool itself runs on your own computer, so its words will differ from any example here.Your task: open the practice folder in VS Code, select the cycle_rent function, and use Continue Edit with your local Ollama model so that the shop charges 20 rupees for every started block of 30 minutes and rejects fewer than 1 minute with a message that contains minutes.
Setup (practice folder jasmine-cycles)
- Create the practice folder with the name shown below, and save the two files from this section inside it.
- Create a virtual environment: on macOS or Linux run
python3 -m venv .venv. On Windows runpy -3 -m venv .venv. - Activate it: on macOS or Linux run
source .venv/bin/activate. In Windows Command Prompt run.venv\Scripts\activate.bat, and in Windows PowerShell run.venv\Scripts\Activate.ps1. - Install pytest inside the virtual environment:
python -m pip install pytest.
Starter cycle_rent.py (it rounds the time down instead of up, so 31 minutes costs only 20 rupees, and 0 or negative minutes are accepted):
def cycle_rent(minutes):
"""Fictional Jasmine Cycle Rental: 20 rupees for every started block of 30 minutes."""
return minutes // 30 * 20
Simple tests test_cycle_rent.py:
import pytest
from cycle_rent import cycle_rent
def test_exactly_thirty_minutes():
assert cycle_rent(30) == 20
def test_exactly_one_hour():
assert cycle_rent(60) == 40
def test_ninety_minutes():
assert cycle_rent(90) == 60
def test_one_minute_starts_a_block():
assert cycle_rent(1) == 20
def test_thirty_one_minutes_starts_a_second_block():
assert cycle_rent(31) == 40
def test_zero_minutes_is_rejected():
with pytest.raises(ValueError, match="minutes"):
cycle_rent(0)
def test_negative_minutes_is_rejected():
with pytest.raises(ValueError, match="minutes"):
cycle_rent(-10)
Before you ask the AI, run python -m pytest -q in the folder. You should see 4 failed, 3 passed. That proves Python and pytest work before the AI tool is involved.
The exact prompt to try (copy it as it is):
continue-edit-prompt.txtCharge 20 for every started block of 30 minutes, so 1 minute costs 20 and 31 minutes costs 40. If minutes is less than 1, raise ValueError with a message that contains the word minutes. Keep the function name.
HOW to verify your Ollama and Continue setup
- Check that Ollama is running: in a terminal run
curl http://localhost:11434. It should print Ollama is running. If it does not, start it withollama serveor open the Ollama app. - Check the model name: run
ollama list. The model in your Continue config must match one of these names exactly, including the tag, for exampleqwen2.5-coder:7b. - Open the folder and the file: in VS Code choose File and then Open Folder, pick
jasmine-cycles, and opencycle_rent.py. Open the Continue panel from the Activity Bar and pick your local model in the model selector. - Select the function and start Edit: highlight the whole
cycle_rentfunction and pressCtrl+Ion Windows or Linux, orCmd+Ion Mac. Paste the prompt above and press Enter. - Read the inline diff: Continue streams the proposed change into the file as a diff. Accept it only if it rounds up to the next block of 30 minutes and adds the check for minutes.
- Accept or reject: press
Ctrl+Shift+Enteron Windows or Linux, orCmd+Shift+Enteron Mac, to accept all changes. PressCtrl+Shift+Backspaceon Windows or Linux, orCmd+Shift+Deleteon Mac, to reject all changes. To ask for a new attempt on the same code, pressCtrl+IorCmd+Iagain. - Confirm yourself: in the VS Code terminal, with your virtual environment active, run
python -m pytest -q. Expect 7 passed.
What a correct result looks like: The model replaces the rounding down with rounding up, for example (minutes + 29) // 30 or math.ceil(minutes / 30), and adds a check that raises ValueError with minutes in the message. A small local model may need two or three tries, and its code style will differ from run to run, which is fine. The result is correct only when pytest shows 7 passed.
Real pytest output after the fixed file:
pytest-after.txt....... [100%]
7 passed in 0.01s
Optional completed cycle_rent.py (try it yourself first)
Your model may use math.ceil instead of whole-number division. Any version is fine if all 7 tests pass and the test file is unchanged.
def cycle_rent(minutes):
"""Fictional Jasmine Cycle Rental: 20 rupees for every started block of 30 minutes."""
if minutes < 1:
raise ValueError("minutes must be at least 1")
blocks = (minutes + 29) // 30
return blocks * 20
Troubleshooting: common Ollama and Continue problems
- Problem:
curl http://localhost:11434fails or Continue cannot connect. Fix: Ollama is not running. Start it withollama serveor open the Ollama app, and check that nothing blocks port 11434 on your computer. - Problem: Continue shows 404 model not found, try pulling it first. Fix: run
ollama listand compare the names with themodel:line in yourconfig.yaml. Pull the exact tag, for exampleollama pull qwen2.5-coder:7b, because pulling a name without a tag downloads thelatesttag, which may be a different size. - Problem: you see model requires more system memory. Fix: add
defaultCompletionOptionswithcontextLength: 2048under that model inconfig.yaml, or use a smaller model such asqwen2.5-coder:1.5b. - Problem: pressing
Ctrl+Idoes nothing, or Edit uses the wrong model. Fix: check that your local model listseditunderrolesinconfig.yaml, and then reload the config in Continue. Also check that no other extension uses the same shortcut. - Problem: the answer is very slow. Fix: run
ollama psto see which models are loaded and how much memory they use. Close other heavy programs, or switch to a smaller model. The first answer after loading a model is usually the slowest. - Problem: Continue says that agent mode is not supported. Fix: many small local models do not support tool use. Use Edit or Chat for this practice, because they do not need tools.
- Problem: the model also rewrote the docstring or renamed the function. Fix: reject the change and try again with the same short prompt. The tests import
cycle_rentby name, so a renamed function will always fail.
Practice cards: English and spoken Marathi
Each card below explains one idea on its own, so you can save or revise a single card without reading the whole chapter.
Check Ollama before you blame Continue
Select small code for a local model
Continue ला दोष देण्याआधी Ollama तपासा
Local model साठी छोटा code निवडा
Quick quiz
1. What does Ollama do?
Downloads and runs AI models on your own computer, at localhost:11434.
2. Which command downloads a model?
ollama pull <model:tag>.
3. Where is Continue's config?
~/.continue/config.yaml.
4. Which role gives fast inline suggestions?
autocomplete, best with a small model like qwen2.5-coder:1.5b.
Save tokens and money
Local models cost no tokens, so use them for practice, boilerplate and private code. Save paid cloud models for hard problems. Keep the context length small for speed.