Skip to content

Run an LLM on your laptop with Ollama

Download an open-weight model, chat with it offline and call it from Python — in about ten minutes.

NZNarjis Zekhnini6 Oct 20263 min readDrafted with Inky · reviewed by Narjis

You don't need an API key to experiment with language models. Open-weight models run fine on a recent laptop, and Ollama makes installing and running them a one-line job.

Why run locally

  • Privacy: your prompts and documents never leave your machine.
  • Cost: no per-token bills while you prototype.
  • Learning: you can see how model size, quantisation and context length affect speed and quality.

Install and run

Install Ollama from its website (macOS, Windows and Linux are supported), then in a terminal:

ollama pull llama3.2        # a small model, a few GB
ollama run llama3.2         # chat in the terminal
ollama list                 # see installed models

As a rough guide, small models (1–4B parameters) run on most laptops; 7–8B models want 16 GB of RAM or a recent Apple Silicon Mac; bigger models need a strong GPU.

Call it from Python

Ollama runs a local server on port 11434 with a simple HTTP API.

import requests
 
def chat(prompt, model="llama3.2"):
    r = requests.post(
        "http://localhost:11434/api/chat",
        json={"model": model, "messages": [{"role": "user", "content": prompt}], "stream": False},
        timeout=120,
    )
    r.raise_for_status()
    return r.json()["message"]["content"]
 
print(chat("Explain LoRA in two sentences."))

Ollama also exposes an OpenAI-compatible endpoint at http://localhost:11434/v1, so many existing tools work by just changing the base URL.

Tips

  • Quantised models (for example 4-bit) are smaller and faster with a modest quality drop — usually the right trade-off on a laptop.
  • Context length uses memory; keep prompts short on small machines.
  • Compare honestly. Local models are great for drafts, classification and private data; for hard reasoning, a frontier API model may still be worth it.

Takeaways

  • ollama pull + ollama run gets you a working local model.
  • A local HTTP API makes it scriptable from Python.
  • Pick the model size your hardware can comfortably run.

Keep reading

Get the next tutorial by email

One email a week. No spam.

Run an LLM on your laptop with Ollama · Tokenfield