Back to AI Tricks
Local AI
2026-04-08

How to run Claude Code with Gemma 4 completely free

Run Claude Code locally using Google's Gemma 4. No subscriptions, no API keys, 100% private.

Beginner8GB RAM (16GB Recommended)ClaudeGemma 4OllamaFreeCoding
1

Step 1: Install Ollama (The Engine)

Ollama is what runs AI models locally on your machine.

macOS

Go to ollama.com/download, click download for Mac, and install like any normal app.

Windows

Go to ollama.com/download, click download and run the installer.

Linux

Run this command in your terminal.

curl -fsSL ollama.com/install.sh | sh

After installing, verify the installation by running:

ollama --version
2

Step 2: Download Gemma 4

Pick the model size based on your machine's RAM:

• 8GB RAM: ollama pull gemma4:e2b • 16GB RAM: ollama pull gemma4:e4b (Recommended) • 32GB+ RAM: ollama pull gemma4:26b
These are large downloads (7GB - 18GB). Ensure you have a stable connection and enough disk space.
ollama pull gemma4:e4b

Verify your downloaded models with:

ollama list
3

Step 3: Install Claude Code Extension

Claude Code is your interface for interacting with the AI.

1. Open VS Code. 2. Press `Ctrl + Shift + X` (or Cmd+Shift+X on Mac). 3. Search for 'Claude Code' by Anthropic and install it. 4. You will see a ⚡ icon in your sidebar.

4

Step 4: Connect Claude Code to Ollama

We're redirecting Claude to your local machine to keep everything 100% private.

1. Press `Ctrl + Shift + P` (Cmd+Shift+P on Mac). 2. Search: 'Open User Settings (JSON)'. 3. Paste this config inside the JSON file:

"claude-code.env": {
  "ANTHROPIC_BASE_URL": "http://localhost:11434",
  "ANTHROPIC_API_KEY": "",
  "ANTHROPIC_AUTH_TOKEN": "ollama"
}
5

Step 5: Run Everything

Now you're ready to start prompting!

ollama serve
Everything is connected! Open the Claude Code sidebar (⚡), type your model name (e.g., `gemma4:e4b`), and start coding.

Troubleshooting & FAQs

Unable to connect / Connection Refused

Ensure 'ollama serve' is running in a terminal window.

Asked to sign in or API error

Double-check your JSON configuration in Step 4 for syntax errors.

Very slow responses

Your model might be too large for your RAM. Try 'gemma4:e2b'.

Was this trick helpful?

Share it with your fellow AI enthusiasts!