How to Run Claude Code for Free with Ollama (MacOS)

In this tutorial, you will learn how to run Claude Code for Free in MacOS, using Ollama.

Thanks to Ollama’s Anthropic API compatibility, you can now run Claude Code for FREE running on open-source LLMs via Ollama. In the Ollama’s official announcement, you will find everything that you need to get started with other Operating Systems and get the ability to:

  • run Claude Code locally
  • connect to open-source models

In this tutorial, I will show you how to get it up and running.

TL:DR; Run Claude Code with Ollama

# Skip if installed
# $ curl -L https://ollama.com/download/Ollama-darwin.zip -o Ollama-darwin.zip
# $ unzip Ollama-darwin.zip 
# $ mv Ollama.app /Applications/

# Install Claude
$ curl -fsSL https://claude.ai/install.sh | bash

# Install Local Model
$ ollama pull gpt-oss:20b

# Run the Command
$ ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 claude --model gpt-oss:20b  

Install or Upgrade Ollama

Verify if Ollama is installed:

$ ollama --version

The version should be at least 0.14.2.

ollama version is 0.14.2

If Ollama is Not installed

$ curl -L https://ollama.com/download/Ollama-darwin.zip -o Ollama-darwin.zip
$ unzip Ollama-darwin.zip 
$ mv Ollama.app /Applications/
$ ollama --version      
ollama version is 0.14.2

Install Claude Code

Once Ollama is installed, install Claude Code.

$ curl -fsSL https://claude.ai/install.sh | bash

Configure Environment Variables

Configure environment variables to use Ollama:

$ export ANTHROPIC_AUTH_TOKEN=ollama
$ export ANTHROPIC_BASE_URL=http://localhost:11434

Pull The Model

$ ollama pull qwen3-coder

This task will take a while, and once over, you can open up your Python code editor.

Run Claude on Ollama

$ ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 claude --model qwen3-coder
Enjoyed This Post?