ByHeartAI
Beginner 15 minVerified Nov 14, 2026

How to Install Ollama and Run an LLM Locally

Install Ollama on Mac, Windows, or Linux, download a local LLM, chat offline, and call the Ollama API from Python or curl.

You will end up with

A private AI model running on your machine, with a local API at localhost:11434 that other tools in these guides can use.

With a downloaded local model in Ollama, you can send prompts to a model on your own computer and chat offline. This guide takes you from installation to your first terminal chat and API request.

What you need

A laptop or desktop from the last few years. 8 GB of RAM runs small models; 16 GB or more (or any recent Apple Silicon Mac, or a PC with a GPU) is comfortable. Models are multi-gigabyte downloads.

Install Ollama

On macOS or Linux:

curl -fsSL https://ollama.com/install.sh | sh

On Windows, in PowerShell:

irm https://ollama.com/install.ps1 | iex

Check it worked:

ollama --version

Run your first model

ollama run gemma4

The first run downloads the model, then drops you into a chat prompt. Ask it something. Type /bye to leave.

gemma4 is one option. The model library lists the rest, with sizes. A rule of thumb: the model file should be clearly smaller than your free RAM (or GPU memory). If a model is slow, pick a smaller one or a more heavily quantized variant.

Manage what is installed

ollama list        # models on disk
ollama ps          # models loaded in memory right now
ollama pull gemma4 # download or update without chatting
ollama rm gemma4   # free the disk space

Call it from code

While Ollama is running it serves a REST API on port 11434. This is what makes it useful for automation: any script or app can now use your local model.

curl http://localhost:11434/api/chat -d '{
  "model": "gemma4",
  "messages": [{ "role": "user", "content": "Why is the sky blue?" }],
  "stream": false
}'

From Python:

pip install ollama
import ollama
 
reply = ollama.chat(
    model="gemma4",
    messages=[{"role": "user", "content": "Summarize RAG in two sentences."}],
)
print(reply["message"]["content"])
Tip

Many tools that expect an OpenAI-style API can be pointed at Ollama instead by setting their base URL to http://localhost:11434/v1. That is how most of the other guides here connect to your local model.

Connect it to an agent

Recent Ollama versions can launch popular agents already wired to your local models:

ollama launch claude     # Claude Code, running on a local model
ollama launch openclaw   # a personal assistant across your chat apps

Running ollama with no arguments shows the full menu of integrations.

If something goes wrong

  • "connection refused" on port 11434: the server is not running. Start the Ollama app, or run ollama serve in a terminal.
  • Very slow answers: the model is too large for your memory and is swapping. Try a smaller model.
  • Out of disk: ollama list, then ollama rm the ones you do not use.

What to do next

Put a proper chat interface on top with Open WebUI, or let it answer questions about your own files with AnythingLLM.

See the local AI setup overview to compare these options and learn when to use each one.

Sources

Open-source tools change quickly. Commands here were checked on Nov 14, 2026; if one fails, the project's README is the source of truth.

Keep building