# 💰 $200/Month → $0 — How Ollama Turned Claude Code Into a Free Tool

**URL:** <https://onehack.st/t/200-month-0-how-ollama-turned-claude-code-into-a-free-tool/319031>\
**Category:** Tutorials & Methods\
**Tags:** programming, tips-tricks\
**Created:** [February 28, 2026, 8:12pm UTC](https://onehack.st/t/200-month-0-how-ollama-turned-claude-code-into-a-free-tool/319031 "2026-02-28T20:12:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Margaret](https://onehack.st/user_avatar/onehack.st/margaret/32/174872_2.png) [@Margaret](https://onehack.st/u/Margaret)\
**Post date:** [February 28, 2026, 8:12pm UTC](https://onehack.st/t/200-month-0-how-ollama-turned-claude-code-into-a-free-tool/319031/1 "2026-02-28T20:12:32Z")

</div>

# ⚡ Ollama Speaks Anthropic Now — Here’s How to Run Claude Code for Free

_Claude Code thinks it’s talking to Anthropic. It’s talking to your machine. $200/month → $0._

**Three environment variables. One command. Claude Code runs against free, local models — and doesn’t know the difference.**

In January 2026, Ollama quietly added Anthropic Messages API compatibility. That one update turned Claude Code — Anthropic’s $200/month terminal coding agent — into a free, offline, fully private coding tool. Same agentic workflow. Same file editing, code navigation, multi-turn conversations. Different brain behind it. Your brain. Running on your GPU. Sending nothing to the cloud.

* * *

> **🧠 What's Actually Happening Here — The 60-Second Version**
>
> Think of Claude Code as a really smart project manager. It reads your files, plans changes, writes code, runs tests, and edits across your codebase. Normally, every time it “thinks,” it calls Anthropic’s servers — and you pay per token.
> 
> Ollama is a local AI model runner. It downloads open-source AI models to your machine and serves them through an API.
> 
> **The trick:** Ollama now speaks the same language as Anthropic’s API. So you tell Claude Code “hey, Anthropic’s server is at localhost:11434” — and it believes you. It sends all its requests to your local Ollama instance instead. Ollama responds using whatever model you picked. Claude Code processes the response like nothing changed.
> 
> **What you keep:**
> 
> - Agentic coding workflow (file reading, editing, terminal commands)
> - Multi-turn conversation context
> - Tool calling and function execution
> - Project-wide code navigation
> 
> **What you trade:**
> 
> - Peak intelligence (local models aren’t Opus-level — yet)
> - Speed on complex multi-file refactors
> - Long context reliability above ~64K tokens
> 
> For everyday coding — scaffolding, tests, boilerplate, quick edits, debugging — local models handle it fine.

> **🔧 Full Setup — 5 Minutes, Any OS**
>
> **Step 1: Install Ollama**
> 
> | OS | Command |
> | --- | --- |
> | **Linux** | `curl -fsSL https://ollama.com/install.sh | sh` |
> | **macOS/Windows** | Download from [ollama.com](https://ollama.com) |
> 
> Verify: `ollama --version` — need **v0.14.0+** for Anthropic API compatibility.
> 
> **Step 2: Pull a coding model**
> 
> ```auto
> ollama pull qwen3-coder
> 
> ```
> 
> Other options depending on your hardware — see the model comparison table below.
> 
> **Step 3: Launch Claude Code with Ollama**
> 
> The fast way (Ollama v0.15+):
> 
> ```auto
> ollama launch claude --model qwen3-coder
> 
> ```
> 
> The manual way (any Ollama version):
> 
> ```bash
> export ANTHROPIC_BASE_URL="http://localhost:11434"
> export ANTHROPIC_AUTH_TOKEN="ollama"
> export ANTHROPIC_API_KEY=""
> claude --model qwen3-coder
> 
> ```
> 
> That’s it. Claude Code is now running locally.
> 
> **Step 4 (optional): Make it permanent**
> 
> Add to `~/.bashrc` or `~/.zshrc`:
> 
> ```bash
> export ANTHROPIC_BASE_URL="http://localhost:11434"
> export ANTHROPIC_AUTH_TOKEN="ollama"
> export ANTHROPIC_API_KEY=""
> 
> ```
> 
> For Windows PowerShell:
> 
> ```powershell
> $env:ANTHROPIC_BASE_URL = "http://localhost:11434"
> $env:ANTHROPIC_AUTH_TOKEN = "ollama"
> $env:ANTHROPIC_API_KEY = ""
> 
> ```
> 
> ⚡ **Pro tip:** Test offline by disconnecting WiFi and running a prompt. If it responds — you’re fully local. Nothing leaves your machine.

> **🏆 Best Models for Claude Code — 2026 Tier List**
>
> Not all models are equal. Context window matters. Tool calling support matters. Coding ability matters.
> 
> | Model | Size | VRAM Needed | Best For | SWE-bench | Context |
> | --- | --- | --- | --- | --- | --- |
> | **[GLM-5](https://ollama.com/library/glm-5)** | 744B MoE / 40B active | Multi-GPU or cloud | Best local coding quality | 77.8% | 128K+ |
> | **[qwen3-coder](https://ollama.com/library/qwen3-coder)** | 480B MoE / ~30B active | 32GB+ RAM | All-around coding + 1M context | 70.6% | 1M |
> | **[gpt-oss:20b](https://ollama.com/library/gpt-oss)** | 20B | 16GB+ | Fast local performance | ~65% | 128K |
> | **[GLM-4.7 Flash](https://ollama.com/library/glm-4.7-flash)** | 30B | 24GB | Best value/speed tradeoff | 73.8% | 200K |
> | **[devstral-2-small](https://ollama.com/library/devstral-small-2)** | 24B | 20GB+ | Solid on Apple Silicon | ~68% | 128K |
> | **[qwen2.5-coder:7b](https://ollama.com/library/qwen2.5-coder)** | 7B | 8GB | Budget hardware, still decent | — | 32K |
> 
> **Cloud models via Ollama (no local GPU needed):**
> 
> | Model | Command | Cost |
> | --- | --- | --- |
> | **GLM-4.7 cloud** | `ollama launch claude --model glm-4.7:cloud` | Free tier available |
> | **qwen3-coder cloud** | `ollama launch claude --model qwen3-coder:480b-cloud` | Free tier available |
> | **minimax-m2.1 cloud** | `ollama launch claude --model minimax-m2.1:cloud` | Free tier available |
> 
> ⚡ **Pro tip:** Ollama recommends models with **at least 64K context** for Claude Code. Smaller context = more confusion on multi-file tasks.

> **💰 The Math — What You're Actually Saving**
>
> | Scenario | Monthly Cost |
> | --- | --- |
> | **Claude Code via Anthropic API (Opus 4.5)** | $100–$200+ depending on usage |
> | **Claude Code via Anthropic API (Sonnet 4.5)** | $17–$100 |
> | **Claude Code via Ollama (local)** | $0 (electricity only) |
> | **Claude Code via Ollama (cloud models)** | $0–$3/month |
> | **Claude Code via cheap API providers** | $3–$10/month |
> 
> Third-party API alternatives can save up to **98%** compared to Anthropic’s Opus pricing. DeepSeek V3.2 runs at ~$0.28 per million tokens. Ollama local is literally free.
> 
> **The real savings compound fast.** Heavy Claude Code users burn through tokens during iterative debugging sessions. A single complex refactor can eat $5–15 in Opus tokens. Locally? That same session costs zero — as many iterations as you want.

> **⚠️ Honest Limitations — What Local Can't Do (Yet)**
>
> | Limitation | Reality |
> | --- | --- |
> | **Complex multi-file refactors** | Local models stumble on 10+ file changes — Opus handles these gracefully |
> | **Long context accuracy** | Above ~64K tokens, local models start losing track. Opus maintains coherence at 200K+ |
> | **Speed** | Expect 20–55 seconds for simple prompts on Apple Silicon. Desktop GPUs are faster but still slower than cloud API |
> | **Reasoning depth** | For architecture decisions and complex debugging chains, Opus/Sonnet still have a meaningful edge |
> | **First-run download** | Models are 8–24GB. First pull takes time depending on your internet |
> 
> **The honest take:** Use local models for 80% of your coding — scaffolding, tests, boilerplate, quick fixes, refactoring single files. Switch to Anthropic’s API for the remaining 20% — complex architecture, multi-file changes, gnarly debugging. Your monthly bill drops from $200 to maybe $20.

> **🛠️ Resources — Everything Referenced**
>
> | Resource | What It Is |
> | --- | --- |
> | [**Ollama Claude Code docs**](https://docs.ollama.com/integrations/claude-code) | Official setup guide |
> | [**Ollama blog announcement**](https://ollama.com/blog/claude) | The January 2026 post that started it all |
> | [**Ollama download**](https://ollama.com) | Install Ollama itself |
> | [**Claude Code install**](https://claude.ai/install.sh) | Install Claude Code CLI |
> | [**Ollama model library**](https://ollama.com/search) | Browse all available models |
> | [**llama.cpp**](https://github.com/ggml-org/llama.cpp) | Alternative local inference engine (more control, harder setup) |
> | [**LM Studio**](https://lmstudio.ai) | GUI-based local model runner (alternative to Ollama) |

* * *

**⚡ Quick Hits**

| Want | Do |
| --- | --- |
| 🚀 Fastest setup | → `ollama launch claude --model gpt-oss:20b` |
| 🧠 Best coding quality (local) | → `ollama pull glm-5` (needs multi-GPU) |
| 💻 Best on 16GB RAM | → `ollama pull gpt-oss:20b` |
| 🍎 Best on Apple Silicon | → `ollama pull devstral-small-2` or `glm-4.7-flash` |
| ☁ No GPU at all | → `ollama launch claude --model glm-4.7:cloud` |
| 💰 Maximum savings | → Local for daily work, Anthropic API for complex-only |

* * *

_Your code stays on your machine. Your wallet stays in your pocket. Anthropic doesn’t need to know._

---

<div class="post-metadata">

**Author:** ![Klaas](https://onehack.st/user_avatar/onehack.st/klaas/32/136151_2.png) [@Klaas](https://onehack.st/u/Klaas)\
**Post date:** [April 26, 2026, 2:44pm UTC](https://onehack.st/t/200-month-0-how-ollama-turned-claude-code-into-a-free-tool/319031/2 "2026-04-26T14:44:23Z")

</div>

Is it possible to determine to use a specific model like Opus 4.6?
