Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

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

WHY

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

WHAT
  • 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:7b for chat, qwen2.5-coder:1.5b for 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

1 · Install Ollama ollama --version 2 · Pull a model ollama pull qwen2.5-coder:7b 3 · Install Continue VS Code Extensions 4 · Edit config.yaml provider: ollama 5 · Chat offline code stays on your PC

Install steps

HOW
  1. Install Ollama. Windows/Mac: download from ollama.com. Linux: curl -fsSL https://ollama.com/install.sh | sh.
  2. Check it: ollama --version.
  3. Make sure it is running: curl http://localhost:11434 should print Ollama is running. If not, run ollama serve.
  4. Pull the models (use pull, not run): ollama pull qwen2.5-coder:7b and ollama pull qwen2.5-coder:1.5b.
  5. Check: ollama list shows both, with the exact tags.
  6. Install Continue: in VS Code press Ctrl+Shift+X, search Continue, install. Or: code --install-extension Continue.continue.
  7. 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 list

Configuration: config.yaml

Open Continue's config (gear icon, or the file ~/.continue/config.yaml). The model name must match ollama list exactly.

~/.continue/config.yaml
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:
      - autocomplete

Settings

  1. After editing, click Reload config in Continue's config selector.
  2. Autodetect: instead of listing models, you can set model: AUTODETECT with provider: ollama; Continue lists what you pulled.
  3. “Model requires more system memory” error: add defaultCompletionOptions: contextLength: 2048 under the model, or use a smaller model.
  4. Agent mode needs tool use. Small local models are weak at it; use chat and edit for best results.
  5. Another PC runs Ollama? set apiBase to that machine's address.

First test: a small function

ASK THE LOCAL MODEL

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.py
def 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.py
from 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 passed

Small models make more mistakes than big ones. Always run the test.

Local (Ollama + Continue)Cloud assistant
PrivacyCode stays on your PCCode goes to the provider
CostFree after downloadPlan or per-token price
QualityGood for small tasksStronger on big tasks
SpeedDepends on your hardwareFast
OfflineYesNo
Rule: download models only with 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.

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.

Practice label: Jasmine Cycle Rental and its rental rate are fictional teaching data. It is not a real business, and no real customer data is used. Passing these tests proves only the listed cases.
Environment (tested): on 16 November 2026 the starter and fixed files below were run on this course's Linux build machine with 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.
Checked against official docs: every menu name, command and setting in this practice was checked on 16 November 2026 against the Continue docs (Ollama guide, Edit quick start and Chat quick start on docs.continue.dev) and the Ollama CLI reference on docs.ollama.com. These tools update often. If a menu name looks different on your screen, search for the same words in the official docs or the Command Palette, and do not guess.

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)

HOW
  1. Create the practice folder with the name shown below, and save the two files from this section inside it.
  2. Create a virtual environment: on macOS or Linux run python3 -m venv .venv. On Windows run py -3 -m venv .venv.
  3. 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.
  4. 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):

cycle_rent.py
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:

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.txt
Charge 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

HOW
  1. 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 with ollama serve or open the Ollama app.
  2. Check the model name: run ollama list. The model in your Continue config must match one of these names exactly, including the tag, for example qwen2.5-coder:7b.
  3. Open the folder and the file: in VS Code choose File and then Open Folder, pick jasmine-cycles, and open cycle_rent.py. Open the Continue panel from the Activity Bar and pick your local model in the model selector.
  4. Select the function and start Edit: highlight the whole cycle_rent function and press Ctrl+I on Windows or Linux, or Cmd+I on Mac. Paste the prompt above and press Enter.
  5. 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.
  6. Accept or reject: press Ctrl+Shift+Enter on Windows or Linux, or Cmd+Shift+Enter on Mac, to accept all changes. Press Ctrl+Shift+Backspace on Windows or Linux, or Cmd+Shift+Delete on Mac, to reject all changes. To ask for a new attempt on the same code, press Ctrl+I or Cmd+I again.
  7. 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.

cycle_rent.py
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

HOW
  1. Problem: curl http://localhost:11434 fails or Continue cannot connect. Fix: Ollama is not running. Start it with ollama serve or open the Ollama app, and check that nothing blocks port 11434 on your computer.
  2. Problem: Continue shows 404 model not found, try pulling it first. Fix: run ollama list and compare the names with the model: line in your config.yaml. Pull the exact tag, for example ollama pull qwen2.5-coder:7b, because pulling a name without a tag downloads the latest tag, which may be a different size.
  3. Problem: you see model requires more system memory. Fix: add defaultCompletionOptions with contextLength: 2048 under that model in config.yaml, or use a smaller model such as qwen2.5-coder:1.5b.
  4. Problem: pressing Ctrl+I does nothing, or Edit uses the wrong model. Fix: check that your local model lists edit under roles in config.yaml, and then reload the config in Continue. Also check that no other extension uses the same shortcut.
  5. Problem: the answer is very slow. Fix: run ollama ps to 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.
  6. 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.
  7. 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_rent by 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.

PRACTICE CARDAI Coding

Check Ollama before you blame Continue

Run curl http://localhost:11434 and expect the words Ollama is running.
Run ollama list and copy the exact model name and tag into your Continue config.
Ravindra Bagale · ravindrabagale.com/ai-coding
PRACTICE CARDAI Coding

Select small code for a local model

Highlight one function and press Ctrl+I or Cmd+I to start Continue Edit.
Accept the inline diff only when the tests pass, and reject it when they do not.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Continue ला दोष देण्याआधी Ollama तपासा

curl http://localhost:11434 चालवा, आणि Ollama is running हे शब्द दिसले पाहिजेत.
ollama list चालवा, आणि model चं नेमकं नाव आणि tag Continue config मध्ये तसंच लिहा.
Ravindra Bagale · ravindrabagale.com/ai-coding
सराव कार्डमराठी

Local model साठी छोटा code निवडा

एकच function select करा आणि Continue Edit सुरू करण्यासाठी Ctrl+I किंवा Cmd+I दाबा.
Tests pass झाले तरच inline diff accept करा, नाहीतर तो reject करा.
Ravindra Bagale · ravindrabagale.com/ai-coding

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

SMART AI USE

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.

Save these cards

INTERVIEW CARDAI Coding

How do you run an AI coding model locally?

Ollama runs the model.
Continue connects it to VS Code/JetBrains via config.yaml.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

Local vs cloud AI

Local: private, free, offline, weaker.
Cloud: stronger, fast, costs money, code leaves PC.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

Local setup in 4

Install Ollama → ollama pull model.
Install Continue.
provider: ollama in config.yaml → Reload.
Ravindra Bagale · ravindrabagale.com/ai-coding