How to run AI models on your own machine with Ollama
Running an AI model on your own machine means what you type stays with you, and you do not pay a provider for every request. Ollama makes it a one-command job. This guide follows the official docs, from installation to calling the model from code.
What you need
- A computer running macOS, Windows or Linux.
- Disk space for the model. The example model in the official docs (Gemma 4 E2B) is about 7.2 GB.
- Enough memory. The docs recommend 8 GB of free VRAM, or unified memory on a Mac. With less, Ollama uses system RAM, but answers can be slower, and larger context windows need more memory.
Step 1: Install Ollama
Download Ollama from ollama.com/download. Open the app, or start from the terminal by typing the command below and following the prompts:
ollamaOn Linux you can install with one command:
curl -fsSL https://ollama.com/install.sh | shIf the server is not running on Linux, start it with ollama serve. To check that everything works, run ollama -v.
Step 2: Run your first model
One command downloads the model and opens a chat on your machine:
ollama run gemma4:e2bWait for the download, then type your question. To leave the chat, type /bye.
Step 3: Use the model from code
Ollama runs a local server on your machine. Pull the model first:
ollama pull gemma4:e2bThen send a request to the local server:
curl http://localhost:11434/api/chat \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4:e2b",
"messages": [
{"role": "user", "content": "Say hello in one sentence."}
],
"stream": false
}'The answer is in the field message.content. Ollama also offers OpenAI- and Anthropic-compatible endpoints for part of their features, such as http://localhost:11434/v1/chat/completions, so many tools can connect to your local model. See the compatibility page in the docs for what is supported.
Windows note: in PowerShell the command may need curl.exe and different quoting. You can also use Python or WSL.
Step 4 (optional): try a coding agent with a local model
From your project folder, launch a coding agent through Ollama:
ollama launch claudeOllama offers to install Claude Code if you do not have it, then asks you to choose the model. Try a simple request such as Explain how this repository is organized. Ollama supports Codex CLI and OpenCode the same way. If the command is not found, update Ollama.
Local or cloud models?
Ollama shows two kinds of models. Local models run on your machine and need no API key. Cloud models need a sign-in and an API key, and they run on Ollama's servers, not on your machine. This guide covers local models.
Common problems
- Very slow, or out of memory: try a smaller model from the library and close heavy applications.
- The command cannot reach the server on Linux: run ollama serve in one window and your commands in another.
- Where are models stored? In ~/.ollama/models on macOS and Linux, and in %USERPROFILE%\.ollama\models on Windows (according to Real Python). Mind your disk space, since models are large.
FAQ
Do I need an account or an API key?
Not for local models. The official docs say sign-in is needed only for cloud models.
Do I need internet?
Downloading the app and the model needs a connection. After that, a local model runs on your machine.
Does it understand Arabic?
It depends on the model you choose, not on Ollama. Test it with Arabic questions from your own field before relying on it.
A new tool every day
I post a free AI tool on X every day, and all sources and paths live in the library.