Claude Code is one of the best AI coding tools around right now. The catch? The more you use it, the bigger the bill gets.
In this guide I’ll show you how I run Claude Code completely free, on my own PC. No API key, no subscription, no usage limits. The AI model runs locally through Ollama, using Qwen 3.8, and the whole thing comes down to one command.
Prefer watching? Here’s the full 5-minute video:
What “Free” Really Means
Let’s be honest up front. “Free” here means no API bill. Claude Code talks to a model running on your own machine instead of a paid cloud API.
What you do pay with is hardware: your GPU, RAM, disk space and a bit of electricity. If you already have a decent PC, this setup costs you nothing extra.
What You Need
The Qwen 3.8 27B model is about 18 GB, so your machine needs enough memory to hold it.
| Must have | Recommended | |
|---|---|---|
| Memory | 32 GB total (RAM + GPU) | 32 GB+ RAM |
| GPU | Optional (much slower without) | 24 GB VRAM (e.g. RTX 4090) |
| Mac | n/a | Apple Silicon, 32 GB+ unified memory |
| Disk | 20 GB free | Fast NVMe SSD |
| OS | Windows, macOS or Linux | n/a |
You’ll also need Ollama 0.15 or newer. We’ll install it in step 2.
No big GPU? It still works. Ollama splits the model between your GPU and RAM, it’s just slower.
Step 1: Install Claude Code
Use the official one-line installer.
macOS, Linux or WSL:
|
|
Windows (PowerShell):
|
|
Check that it installed:
|
|
Step 2: Install Ollama
Ollama is what runs the AI model on your own computer.
macOS or Linux:
|
|
Windows: download the installer from ollama.com.
Then check your version. It must be 0.15 or newer:
|
|
If it’s older, update Ollama before moving on. The next step won’t work on old versions.
Step 3: The Magic Command
This is the one command that does it all:
|
|
That’s it. Ollama starts Claude Code and points it at Qwen 3.8 running locally on your machine. No API key, nothing sent to a paid cloud API, no bill.
Prefer two steps? Download the model first (about 18 GB, so grab a coffee), then launch:
|
|
Quick sanity check that the model works on its own:
|
|
Optional: Make It Permanent with settings.local.json
ollama launch is perfect for getting started. But if you want Claude Code to always use your local model in a project, even when you just type claude, put the settings in a file instead.
Create this file inside your project folder:
|
|
Paste in these settings:
|
|
What each setting does:
| Setting | What it does |
|---|---|
ANTHROPIC_BASE_URL |
Points Claude Code at Ollama on your own machine (port 11434) instead of the cloud |
ANTHROPIC_AUTH_TOKEN |
Required, but Ollama ignores it, so any word works. I use ollama |
ANTHROPIC_API_KEY |
Left empty so no real Anthropic key gets used by accident |
ANTHROPIC_MODEL |
The main model Claude Code uses: your local Qwen |
ANTHROPIC_DEFAULT_*_MODEL |
Maps every built-in model choice (Opus, Sonnet, Fable, Haiku) to Qwen, so switching models never reaches for a paid one |
CLAUDE_CODE_SUBAGENT_MODEL |
Makes sub-agents use Qwen too |
CLAUDE_CODE_MAX_CONTEXT_TOKENS |
How much context Claude Code works with. 65536 = 64k |
Tip:
settings.local.jsonis meant for your own machine, so keep it out of Git. Also set Ollama’s context length to 64k in its settings so it matches the65536above. Too small, and Claude Code forgets your files halfway through a task.
Make sure Ollama is running, then start Claude Code from your project folder as usual:
|
|
Step 4: Build Something
Time to prove it works. I gave Claude Code this prompt:
|
|
Then I let Qwen work. Everything ran on my own PC, with no API calls and no tokens being counted.
When it finished, I opened index.html in the browser and it worked: neon look, arrow keys, score, collisions and a working restart button.
Is it as fast or as sharp as paid Claude? No. But for small projects, learning and side builds, it’s genuinely useful, and it costs nothing.
Troubleshooting
command not found
Start the Ollama app (or run ollama serve), then open a fresh terminal window.
The model won’t load
It’s too big for your machine. Try a smaller Qwen size from the Ollama library.
It’s slow or forgets things mid-task
- Close other GPU-heavy apps (games, video editors, heavy browser tabs).
- Raise the context length in Ollama’s settings so it matches
CLAUDE_CODE_MAX_CONTEXT_TOKENS. - Check the model fits in your GPU memory. If it spills into RAM, it gets much slower.
Claude Code still asks for a login or a key
Double-check ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN in your settings, make sure Ollama is running, and restart Claude Code.
FAQ
Is this really free?
Yes. There’s no API bill. You only use your own hardware.
Do I need an Anthropic account or API key?
No API key is needed for this setup. The model runs locally through Ollama.
Does my code leave my computer?
The AI model runs on your machine, so your prompts go to Ollama at 127.0.0.1, not to a paid cloud model.
Can I use a different model?
Yes. Pull any model from the Ollama library and swap qwen3.8:27b for its name in the command or settings. Coding-focused models work best.
Can I use this inside VS Code?
Yes, and that’s my next video. Subscribe on YouTube so you don’t miss it.
Wrapping Up
That’s the whole setup:
- Install Claude Code
- Install Ollama
- Run
ollama launch claude --model qwen3.8:27b - Build something
If you get stuck, drop your error and your GPU in the video comments and I’ll help you out.
Happy (free) coding! 🚀