- Published on
How to use Ollama with Claude Code
- Authors

- Name
- Ruan Bekker
- @ruanbekker
I was looking for cheaper alternatives to use Claude Code, by using local models on Ollama instead of Cloud Models, sure its less powerful than cloud, but it worked fine for my requirements.

This tutorial I will demonstrate how to:
- Install Ollama
- Pull the Model
qwen3.5:9b - Install Claude Code
- Configuring our Environment to point to Ollama APIs
Ollama
I am using Mac, but if you are using any other Operating System, you can head over to this page to find the installation instructions:
But for short, Mac and Linux can go ahead with:
curl -fsSL https://ollama.com/install.sh | sh
Once Ollama installs, you should be able to run this:
ollama --version
Now we will download the model of choice, I have done some research and the best one that worked for me was qwen3.5:9b, but you can do your own research to determine what works for you. To download a model you can do the following:
ollama pull qwen3.5:9b
Claude Code
Next we will need to install Claude Code CLI Tools, you can head over to the documentation that demonstrates how to install it:
I used homebrew to install it so for me it was:
brew install --cask claude-code
Now we need to tell Claude Code to connect to Ollama that sits on our local host, instead of connecting to the remote claude APIs.
export ANTHROPIC_BASE_URL="http://localhost:11434"
export ANTHROPIC_MODEL="qwen3.5:9b"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_AUTH_TOKEN="ollama"
You can also persist this inside ~/.zshrc or ~/.bashrc depending what shell you are using.
Testing Claude Code
Now for the fun part, we can run the claude cli:
claude
Then we should see a response similar to this:

Inside the chat prompt we can ask it something, for example:
❯ which model are you currently using?
- I'm using qwen3.5:9b - the 9-billion parameter Qwen model family.
This is a smaller, faster model optimized for specific use cases. For more complex tasks that require deeper
reasoning, you could ask me to use a larger model like Claude Opus 4.7 or Claude Sonnet 4.6 if needed.
Thank You
Thanks for reading, if you like my content, feel free to check out my website, and subscribe to my newsletter or follow me at @ruanbekker on Twitter.
- Linktree: https://go.ruan.dev/links
- Patreon: https://go.ruan.dev/patreon
