Gemma 4 vs Claude Code
They are different kinds of thing. Gemma 4 is an open model you download and run. Claude Code is a coding agent from Anthropic, built to run on Claude models. Here is how they compare - and how to use them together.
Independent page, not affiliated with Google or Anthropic ·
Which should you use?
Choose Gemma 4 if
your code must stay on your own machine, you need to work offline, or you want no per-token bill. Expect to do more of the steering yourself.
Choose Claude Code if
you want an agent that plans, edits many files, runs commands and opens pull requests with little hand-holding, and a paid plan is acceptable.
Use both if
you like Claude Code's workflow but want a local model behind it for private or offline work. It runs, with real trade-offs.
What each one is
The fair comparison for Gemma 4 is another model. The fair comparison for Claude Code is another coding tool. People still ask, because both end up writing code.
| Gemma 4 | Claude Code | |
|---|---|---|
| What it is | A family of five open AI models | An agentic coding tool |
| Made by | Google DeepMind | Anthropic |
| What it does | Generates text from text, images and, on smaller sizes, audio | Reads your codebase, edits files, runs commands and works with git |
| Where it runs | Your phone, laptop, workstation or server | Terminal, VS Code, JetBrains, a desktop app and the web |
| The model behind it | Is the model | Anthropic's Claude models, by default |
| What you need | Enough memory for the size you pick | A Claude subscription or an Anthropic Console account |
| Licence | Apache 2.0, open weights | Commercial product |
From Google's Gemma 4 model card and Anthropic's Claude Code overview. Gemma 4 on its own is not an agent: to edit files and run commands it needs a tool around it. Sizes are on the models page; what the model can do is under capabilities.
How they compare for coding work
| Question | Gemma 4, run locally | Claude Code on Claude models |
|---|---|---|
| Where does my code go? | Nowhere - it stays on your machine | To Anthropic's service, or your cloud provider |
| Does it work offline? | Yes | No |
| What does it cost? | Free, beyond your hardware and electricity | A monthly plan or per-token billing |
| Setup | Install a runtime, download 7 - 20 GB | One install command and a sign-in |
| Agent features | None built in - you add a tool | Planning, multi-file edits, git, MCP, hooks, parallel agents |
| Long, multi-step tasks | Its weakest area, especially on small sizes | What the tool is designed for |
| Hardware needed | 16 GB of memory or more for useful coding | Any computer |
| Can I modify or fine-tune it? | Yes | No; you configure it with instructions, skills and hooks |
| Who supports it? | Community and your own team | Anthropic |
Green marks the side with the practical advantage on that row; this is the site's summary, not a score. Gemma 4's known gaps are in limitations; other model match-ups are in the model comparison and Gemma 4 vs Qwen 3.5.
What each one costs
They change - check the linked pages before you budget.
Claude Code
| Plan | Price |
|---|---|
| Free | Claude Code not included |
| Pro | $20 a month |
| Max | from $100 a month |
| Team, per seat | $25 or $125 a month |
| API, Sonnet 5.5 | $2 in / $10 out per million tokens |
| API, Opus 5.5 | $4 in / $20 out per million tokens |
From Anthropic's pricing page. Annual billing is cheaper on some plans.
Gemma 4
| How you run it | Price |
|---|---|
| On your own hardware | Free |
| Hosted 31B, OpenRouter | $0.09 in / $0.34 out per million tokens |
| Hosted 26B A4B, OpenRouter | $0.042 in / $0.22 out per million tokens |
Full breakdown on the pricing page. "Free" still means buying or owning a machine with enough memory - see the VRAM guide.
How good is Gemma 4 at code?
Google's published scores. Writing a single solution holds up well across sizes; acting as an agent over many steps falls away quickly on the small models.
LiveCodeBench v6
Tau2
From Google's model card. All sizes and tests are on the benchmarks page.
Run Claude Code on a local Gemma 4
Ollama speaks the same API format Claude Code uses, so you can point the tool at a Gemma 4 model on your own machine. You keep Claude Code's interface; Gemma 4 does the thinking.
# Needs Ollama and Claude Code installed
ollama pull gemma4:26b
ollama launch claude
Ollama's launcher sets everything up and lets you choose the model. From Ollama's Claude Code integration guide.
# No GPU? Ollama also hosts Gemma 4 (your code leaves your machine)
ollama launch claude --model gemma4:cloud
export ANTHROPIC_AUTH_TOKEN=ollama export ANTHROPIC_API_KEY="" export ANTHROPIC_BASE_URL=http://localhost:11434 claude --model gemma4:26b
The three variables tell Claude Code to talk to Ollama on your machine instead of Anthropic. On Windows PowerShell, use $env:NAME="value" instead of export.
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY claude
Clearing the variables returns Claude Code to your normal Claude sign-in.
Give it room
Ollama recommends a context length of 64K or more for larger repositories. Local apps often default to far less.
Use current weights
The July 2026 refresh fixed Gemma 4's tool calling. Re-pull any model you downloaded before then.
Start small
Try a single-file task first. If files are not being edited, tool calling is not getting through.
New to either tool? Install Claude Code from Anthropic's guide and Ollama via the install guide; model files are in the download hub and how to download. For other servers, see self-hosting and the runtime selector.
What works and what stops working
Ollama covers the core of the API Claude Code relies on, but not all of it.
| Feature | With Ollama | What it means for you |
|---|---|---|
| Messages, streaming, system prompts | Works | The basic conversation loop runs |
| Tool calling | Works | File reads, edits and shell commands can happen |
| Images | Works | Screenshots can be read |
| Thinking | Works | Reasoning before answering is available |
| Prompt caching | Not supported | The whole conversation is re-read every turn, so long sessions slow down |
| Forcing a specific tool | Not supported | The model decides which tool to use, or whether to use one |
| Token counting | Not supported | Usage and context figures may be estimates |
| PDF input and citations | Not supported | Convert documents to text first |
| Batches | Not supported | No background batch jobs |
From Ollama's Anthropic compatibility reference; the right-hand column is this site's reading of it. Clearing the conversation between tasks keeps sessions quick.
Which Gemma 4 size to put behind it
| Model | Ollama tag | Download | Tau2 | Verdict |
|---|---|---|---|---|
| Gemma 4 26B A4B | gemma4:26b-a4b-it-qat | 16 GB | 68.2 | The practical pick: quick replies, fits a 24 GB GPU |
| Gemma 4 31B | gemma4:31b-it-qat | 19 GB | 76.9 | Best results, slower per token |
| Gemma 4 12B | gemma4:12b-it-qat | 7.2 GB | 69.0 | The realistic floor, for a 16 GB laptop |
| Gemma 4 E4B / E2B | gemma4:e4b · gemma4:e2b | 4 - 10 GB | 42.2 / 24.5 | Not suited to driving an agent |
Download sizes from Ollama's tags page, October 2026; Tau2 from Google's model card. Verdicts are this site's guidance. A long coding session needs memory beyond the download size - plan with the VRAM guide, and see QAT builds, the 12B guide, specs and Mac setup.
Where a local Gemma 4 fits, and where it does not
General guidance drawn from the scores above, not a measured test of this setup.
Reasonable to expect
- Edits to one file or one function
- Explaining unfamiliar code
- Writing tests and docstrings
- Boilerplate and repetitive changes
- Commit messages and summaries
- Work on confidential or air-gapped code
Likely to disappoint
- Long tasks left to run unattended
- Refactors that span many files
- Debugging through several layers
- Very long sessions without clearing
- Recovering after a tool call fails
- Anything on the E2B or E4B models
# Inside a Claude Code session, ask it to hand a small job to local Gemma:
ollama run gemma4:12b "Write a one-line commit message for this diff" < changes.diff
Prompt advice for code is in the prompting guide. To build your own tooling on Gemma 4 instead, start with the API page; to try prompts first, use the playground or chat.
Is Gemma 4 a replacement for Claude Code?
Not by itself. Gemma 4 is a model; Claude Code is a tool that drives a model. Gemma 4 can sit behind Claude Code or another coding tool, but it does not edit files or run commands on its own.
Can Claude Code use Gemma 4?
Yes, through Ollama, which accepts the API format Claude Code sends. Anthropic does not support using non-Claude models this way, so treat it as an unofficial setup.
Is running Claude Code on Gemma 4 free?
With a local model there is no per-token charge and the Claude Code CLI is pointed away from Anthropic's service. You still need hardware able to run a 12B or larger model.
Will I get the same results as with Claude models?
Do not expect to. Claude Code is built and tested for Claude models, and multi-step agent work is where Gemma 4's own scores are lowest. For short, well-scoped tasks the gap matters less.
Why does it get slower as the session goes on?
Ollama does not support prompt caching, so the full conversation is processed again on every turn. Clear the conversation between tasks.
The model replies but never edits files. Why?
Tool calls are not getting through. Update Ollama, re-pull the model for the July 2026 fixes, and use a 12B or larger size.
Does my code leave my machine?
Model requests stay on your machine when Claude Code is pointed at a local Ollama model. Claude Code's own telemetry settings are separate - check its documentation if you need a fully isolated setup. Your code does leave if you use a hosted option such as gemma4:cloud, or Claude models.
Is Gemma 4 safe to let loose on a repository?
Review what any agent proposes before it runs, whatever the model. Keep Claude Code's permission prompts on, and work in a branch. See safety and the features page.
Try the local route
Download a Gemma 4 model, point your tools at it and see how far it takes you.