latentstack
Blog
EngineeringBy Suraj5 min read

How to run an AI coding assistant locally on your laptop (free, private, offline)

Run an open-source coding model on your own computer with Ollama or LM Studio and connect it to VS Code. What hardware you need, which model sizes fit your RAM, step-by-step setup, realistic expectations versus cloud models, and privacy and security tips.

How to run an AI coding assistant locally on your laptop (free, private, offline)

Quick answer: Install Ollama (or LM Studio), download an open-source coding model sized for your RAM (around 7B parameters for 8–16 GB, 14B for 16–32 GB, 30B+ for 32 GB or more), then connect it to VS Code with an extension such as Continue. Your code never leaves your machine and there's no monthly bill, though local models are slower and less capable than the best cloud models.

Why run a coding model locally?

  • Privacy: your code, secrets and client projects stay on your computer. Useful for confidential work or strict company policies.
  • No subscription: after the download, it's free to use.
  • Works offline: on flights, trains or locked-down networks.
  • No rate limits: use it as much as your hardware allows.

The trade-off: local models are smaller than frontier cloud models, so they're best for autocomplete, explanations, small edits and boilerplate, rather than large multi-file refactors.

What hardware do you need?

The main limit is memory: the model must fit in RAM (or in GPU VRAM for speed). Models are usually downloaded in compressed ("quantized") form, which makes them much smaller with a modest quality loss.

Your machine Model size to try What to expect
8 GB RAM ~3B–7B Basic autocomplete and explanations; slow on CPU
16 GB RAM / Apple Silicon ~7B–14B Good everyday help
32 GB RAM / 12 GB+ GPU ~14B–32B Noticeably better reasoning
64 GB+ / high-end GPU 30B+ Closest to cloud quality, still slower

Apple Silicon Macs (M-series) are particularly good at this, because their unified memory works like GPU memory. On Windows and Linux, an NVIDIA GPU makes a big difference to speed.

Step 1: install a local model runner

Option A: Ollama (simple, command line)

Download Ollama from ollama.com for macOS, Windows or Linux, then check it works:

ollama --version

Option B: LM Studio (desktop app)

LM Studio gives you a graphical app to browse, download and chat with models, and it can run a local server that other tools connect to. It's the friendliest choice if you prefer not to use the terminal.

Step 2: download a coding model

Open-source coding models are released often, so check the Ollama library or LM Studio's model browser for the current best options. Well-established families include Qwen Coder and DeepSeek Coder. For example:

ollama pull qwen2.5-coder:7b
ollama run qwen2.5-coder:7b

Type a coding question to test it, and /bye to exit. Pick the size from the table above; if responses are painfully slow, choose a smaller model.

Check the licence before using a model for commercial work. Most popular coding models have permissive licences, but some restrict commercial use.

Step 3: connect it to VS Code

  1. Install the Continue extension from the VS Code marketplace (other extensions with local-model support work similarly).
  2. Open Continue's settings and add a model with Ollama as the provider and your model name (for example qwen2.5-coder:7b).
  3. Optionally set a smaller, faster model for tab autocomplete and a larger one for chat.

You now have chat, explanations and inline autocomplete in your editor, running entirely on your machine.

Getting good results from small models

  • Give focused context: select the relevant function instead of asking about the whole project.
  • Ask for small changes: one function or one bug at a time.
  • Use it for what it's good at: boilerplate, tests, regex, SQL, explanations, docstrings.
  • Review everything: smaller models make more mistakes, and they can invent package names, which is a real security risk (see slopsquatting in our AI coding guide).
  • Mix and match: many developers use a local model for everyday autocomplete and a cloud model for hard problems.

Local vs cloud coding assistants

Local model Cloud assistant
Privacy Code stays on your machine Code sent to a provider
Cost Free after setup (plus hardware) Monthly subscription or usage fees
Quality Good for everyday tasks Best for complex reasoning and large changes
Speed Depends on your hardware Fast, consistent
Offline Yes No
Agent features Limited Full agents that edit files and run commands

Security tips

  • Download models and tools only from official sources. Model files and editor extensions are part of your supply chain, and attackers target popular AI tooling (see the LiteLLM supply-chain attack).
  • Keep the local server private: by default Ollama listens on your own machine. Don't expose it to the internet without authentication.
  • Still don't paste secrets into prompts out of habit. Treat local tools with the same care.

Frequently asked questions

Can I run an AI coding assistant locally for free?

Yes. Tools like Ollama and LM Studio let you download open-source coding models and run them on your own computer at no cost, and extensions such as Continue connect them to VS Code.

How much RAM do I need to run a local coding model?

About 8 GB for small 3B–7B models, 16 GB for comfortable 7B–14B models, and 32 GB or more for 14B–32B models. A GPU or an Apple Silicon Mac makes them much faster.

Is a local AI coding model as good as Copilot or Claude?

Not usually. Local models are smaller, so they're great for autocomplete, explanations and small edits but weaker at complex reasoning and large multi-file changes than top cloud models.

Which local model is best for coding?

Open coding models improve quickly, so check the Ollama library or LM Studio's model browser for current options. Qwen Coder and DeepSeek Coder are well-established families; choose the largest size your hardware runs comfortably.

Is running AI models locally private?

Yes. When a model runs locally with Ollama or LM Studio, your prompts and code stay on your computer. Keep the local server private and download models only from trusted sources.

Can I use a local model with VS Code?

Yes. Extensions like Continue can connect VS Code to a local model served by Ollama or LM Studio for chat, explanations and autocomplete.

Sources

Found this useful?

Leave a like, share it with someone who's building with AI, or tell me what you think below.

Comments

Comments

Comments are public. Be kind. See the privacy policy.

    Get the next noteComing soon

    One short email when a new post lands. No spam.