Featured image of post Claude Code For Free: Local Setup with Ollama + Qwen 3.8

Claude Code For Free: Local Setup with Ollama + Qwen 3.8

Run Claude Code for free on your own PC. No API key, no subscription, no bill. A step-by-step local setup with Ollama and Qwen 3.8, plus the exact settings file and prompt I used.

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:

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

Windows (PowerShell):

1
irm https://claude.ai/install.ps1 | iex

Check that it installed:

1
claude --version

Step 2: Install Ollama

Ollama is what runs the AI model on your own computer.

macOS or Linux:

1
curl -fsSL https://ollama.com/install.sh | sh

Windows: download the installer from ollama.com.

Then check your version. It must be 0.15 or newer:

1
ollama --version

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:

1
ollama launch claude --model qwen3.8:27b

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:

1
2
ollama pull qwen3.8:27b
ollama launch claude --model qwen3.8:27b

Quick sanity check that the model works on its own:

1
2
ollama run qwen3.8:27b
# say hi, then type /bye to exit

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:

1
2
3
your-project/
└── .claude/
    └── settings.local.json

Paste in these settings:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:11434",
    "ANTHROPIC_AUTH_TOKEN": "ollama",
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8:27b",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.8:27b",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "65536"
  }
}

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.json is 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 the 65536 above. 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:

1
claude

Step 4: Build Something

Time to prove it works. I gave Claude Code this prompt:

1
2
3
4
5
6
Create a simple Snake game in a single index.html file
using HTML, CSS, and vanilla JavaScript.
Use a neon cyberpunk design, arrow-key controls, score tracking,
collision detection, and a restart button.
No external libraries or files.
Save the complete, working code to index.html.

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:

  1. Install Claude Code
  2. Install Ollama
  3. Run ollama launch claude --model qwen3.8:27b
  4. 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! 🚀

comments powered by Disqus