Ollama for beginners: run your first local AI model in 5 minutes

Build Guides

Ollama for beginners: run your first local AI model in 5 minutes

Close-up of two fluffy beige llamas, with a brown llama in the background
Photo by Anthony 🙂 on Pexels

Ollama runs open AI models on your own Mac, Windows or Linux machine. Here's how to install it, run your first model, learn the commands you'll actually use, connect it to your app or coding agent, and what hardware you need.

In this article
  1. Step 1: install
  2. Step 2: run your first model
  3. Step 3: the commands you'll actually use
  4. Step 4: give it a personality (Modelfile)
  5. Step 5: call it from your app
  6. Step 6: connect a coding agent
  7. Good habits

Local AI is one of the biggest conversations on X right now: we counted about 9,300 posts on local models and Ollama in our sample. If you've never run a model on your own machine, Ollama is the easiest place to start. It's free to run locally, needs no API key, and your prompts stay on your computer.

Step 1: install

Download Ollama for macOS, Windows or Linux and open the app. Or open a terminal and run:

ollama

Then follow the setup prompts. You can sign in for cloud models or pick a local one. This guide is about local.

Windows: you need Windows 10 22H2 or newer. No admin rights are required; Ollama installs into your home folder. Linux: if the server isn't running, start it with ollama serve.

Step 2: run your first model

ollama run gemma4:e2b

Ollama downloads the model and opens a chat in your terminal. Type a question; type /bye to leave.

Will my computer handle it? Ollama says the download is about 7.2 GB, and it recommends 8 GB of available VRAM, or unified memory on a Mac. With less, Ollama can use system RAM, but responses may be slower. Larger context windows need more memory. Our VRAM guide explains the maths.

Tips for the chat:

  • Wrap multi-line input in """ … """.
  • Vision models can read images: ollama run gemma4 "What's in this image? ./screenshot.png"

Step 3: the commands you'll actually use

Command Does
ollama run <model> chat with a model (downloads it first if needed)
ollama pull <model> download without chatting
ollama ls list downloaded models
ollama ps show models loaded in memory right now
ollama stop <model> unload a running model
ollama rm <model> delete a model and free disk space
ollama serve start the server (mostly Linux)

Models take up a lot of disk, from a few GB to hundreds. On Windows, set the OLLAMA_MODELS environment variable to keep them on another drive.

Step 4: give it a personality (Modelfile)

Create a file named Modelfile:

FROM gemma4
SYSTEM """You are a patient coding tutor. Explain things in plain English."""

Then build it with ollama create (see ollama create --help for naming options). It's a quick way to save a system prompt you use often.

Step 5: call it from your app

Ollama runs a local server at http://localhost:11434. It speaks its own API and OpenAI- and Anthropic-compatible ones:

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "gemma4:e2b", "messages": [{"role": "user", "content": "Say hello in one sentence."}]}'

With the OpenAI SDK, change two lines:

from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")  # key required but ignored

Ollama supports a subset of the OpenAI API, so test the features you rely on.

Step 6: connect a coding agent

From your project folder:

ollama launch claude     # Claude Code
ollama launch codex      # Codex CLI (install it first)
ollama launch opencode   # OpenCode

Ollama offers to install Claude Code or OpenCode if they're missing. Pick a model when prompted, then try: "Explain how this repository is organized." A small starter model will struggle with real agent work. See our comparison of local coding models and the full OpenCode + local LLM setup.

Good habits

  • Start small, then go bigger. Get a small model working before downloading a 60 GB one.
  • Check ollama ps if your computer slows down. A loaded model holds memory until it's stopped or unloaded.
  • Local isn't automatically safe. Agents connected to local models can still run commands. Read running coding agents safely.
  • Check the licence on each model page before you build a product on it.

FAQ

Is Ollama free?

Running models locally needs no API key. Ollama also offers cloud models, which need you to sign in or use an API key and have their own usage limits.

What computer do I need for Ollama?

For Ollama's quickstart model, Gemma 4 E2B, it recommends 8 GB of available VRAM or unified memory on a Mac. Bigger models and longer context windows need more. On Windows, it needs Windows 10 22H2 or newer.

Where does Ollama store models?

In your home directory by default. Models can be tens to hundreds of GB. On Windows, set the OLLAMA_MODELS environment variable to store them elsewhere.

Can I use Ollama with the OpenAI SDK?

Yes. Point the client at http://localhost:11434/v1/. The SDK requires an API key value, but Ollama ignores it locally. Ollama supports a subset of the OpenAI API.

Can Ollama run Claude Code or Codex?

Ollama can launch Claude Code, Codex CLI and OpenCode with Ollama models via `ollama launch`. You'll still need a model capable enough for agent work, which usually means a larger one.

Sources

  1. Ollama docs, Quickstarthttps://docs.ollama.com/quickstart
  2. Ollama docs, CLI referencehttps://docs.ollama.com/cli
  3. Ollama docs, Windowshttps://docs.ollama.com/windows
  4. Ollama docs, OpenAI compatibilityhttps://docs.ollama.com/api/openai-compatibility
Matching resources

Matching resources

Newsletter

The Codema publication. Consent is required. You are not subscribed until you confirm from the email, and nothing is stored if email delivery is not connected.