Run Claude Code completely free forever, locally on your device using open-weight models via Ollama
No cloud, all local
No API keys needed
Use GPT-OSS models
Go to ollama.com
Download and install Ollama for your OS.
After installing:
Very Important Step:
This is required for:
We'll use GPT-OSS 20B, which works well with Claude Code.
Open Terminal and paste:
ollama run gpt-oss:20bWhat happens:
bye and press Enter to exitTo confirm it's installed:
ollama listOpen your browser and go to:
You should see:
Ollama is running
If yes β you're good to go β
macOS:
brew install anthropic/tap/claudeVerify installation:
claude --versionYou should see a version number (for example 2.1.x). If not, update Claude Code before continuing.
IMPORTANT STEP: Connect Claude Code β Ollama β GPT-OSS
Go to any folder where you want to code, then paste:
ANTHROPIC_AUTH_TOKEN=ollama \ ANTHROPIC_BASE_URL=http://localhost:11434 \ claude --model gpt-oss:20b
When prompted:
π₯ That's it. Claude Code is now running locally with an open-weight model.
Try a real example to verify everything is working:
"Create a simple Python script that prints Hello World"
Claude Code should create the file, write the code, and confirm it's done.