coding by Ryan Caldwell

Running AI Agents Offline with Ollama on M1 Mac

How Ollama runs open language models locally on a Mac, exposing a local REST API for building AI agents without a cloud connection.

Running AI Agents Offline with Ollama on M1 Mac

Ollama is an open-source tool for running open large language models on local hardware. According to the project repository at https://github.com/ollama/ollama, it is built on the llama.cpp project founded by Georgi Gerganov, and it is distributed under the MIT license. For developers building AI agents on an Apple Silicon Mac, Ollama provides a way to download a model and interact with it through a local server rather than a hosted cloud API.

Installing and Running a Model

On macOS, Ollama can be installed with a shell command, curl -fsSL https://ollama.com/install.sh | sh, or by downloading the application package manually. The repository also lists installers for Windows, Linux, and an official Docker image.

Once installed, running the ollama command prompts the user to run a model or connect to an application. A specific model can be started directly, for example ollama run gemma4, which downloads the model on first use and then opens an interactive session. The repository references models including Kimi-K2.6, GLM-5.1, MiniMax, DeepSeek, gpt-oss, Qwen, and Gemma, with the full catalog published at ollama.com/library.

The Local REST API

The piece that makes Ollama useful for agent development is its REST API, which it exposes at http://localhost:11434. Because the address points to the local machine, requests do not travel to an external service. The repository shows a chat endpoint at /api/chat that accepts a model name and a list of messages:

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

An agent built on top of this endpoint sends prompts and reads responses the same way it would against a hosted service, with the difference that the model runs on the developer’s own machine. The stream flag controls whether the response is returned all at once or as a stream of tokens.

Official Libraries

For developers who prefer not to call the HTTP API directly, Ollama publishes official client libraries. The Python library is installed with pip install ollama, and the JavaScript library with npm i ollama. These wrap the local API so that an agent’s code can request completions through standard function calls.

The repository also references integration commands such as ollama launch claude, along with options for other coding tools, indicating that Ollama is positioned to plug into existing developer workflows rather than replace them.

Why Local Execution Helps Agents

Running a model on localhost keeps prompts and responses on the machine where the agent runs. That arrangement suits situations where a network connection is unavailable or where sending data to a third-party service is undesirable. Because the model files are downloaded once and served locally, the same agent code can run without a connection after the initial download.

Ollama does not remove the practical limits of local hardware. Larger models demand more memory and compute, and the repository points users to its model library to compare available options. For agent builders on an M1 Mac, the value is a consistent local endpoint, open models, and client libraries that mirror the patterns already used for cloud-based language model APIs.

Source: github.com