Gemma 4 / Gemma 4 vs Claude Code

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 ·

Gemma 4An open model You download and run itFree · private · offline Claude CodeA coding agent Reads, edits, runs commandsBuilt for Claude models vs or use them together
A model and a tool - not a like-for-like contest.
Short answer

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.

How to set it up →

Basics

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 4Claude Code
What it isA family of five open AI modelsAn agentic coding tool
Made byGoogle DeepMindAnthropic
What it doesGenerates text from text, images and, on smaller sizes, audioReads your codebase, edits files, runs commands and works with git
Where it runsYour phone, laptop, workstation or serverTerminal, VS Code, JetBrains, a desktop app and the web
The model behind itIs the modelAnthropic's Claude models, by default
What you needEnough memory for the size you pickA Claude subscription or an Anthropic Console account
LicenceApache 2.0, open weightsCommercial 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.

Side by side

How they compare for coding work

QuestionGemma 4, run locallyClaude Code on Claude models
Where does my code go?Nowhere - it stays on your machineTo Anthropic's service, or your cloud provider
Does it work offline?YesNo
What does it cost?Free, beyond your hardware and electricityA monthly plan or per-token billing
SetupInstall a runtime, download 7 - 20 GBOne install command and a sign-in
Agent featuresNone built in - you add a toolPlanning, multi-file edits, git, MCP, hooks, parallel agents
Long, multi-step tasksIts weakest area, especially on small sizesWhat the tool is designed for
Hardware needed16 GB of memory or more for useful codingAny computer
Can I modify or fine-tune it?YesNo; you configure it with instructions, skills and hooks
Who supports it?Community and your own teamAnthropic

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.

Cost

What each one costs

They change - check the linked pages before you budget.

Claude Code

PlanPrice
FreeClaude Code not included
Pro$20 a month
Maxfrom $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 itPrice
On your own hardwareFree
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.

Coding ability

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

Writing code for fresh problems, percent solved
Gemma 4 31B80.0%
Gemma 4 26B A4B77.1%
Gemma 4 12B72.0%
Gemma 4 E4B52.0%
Gemma 4 E2B44.0%

Tau2

Multi-step agent tasks with tools, average of three runs
Gemma 4 31B76.9%
Gemma 4 26B A4B68.2%
Gemma 4 12B69.0%
Gemma 4 E4B42.2%
Gemma 4 E2B24.5%
Why there are no Claude numbers here. Claude Code is a tool, not a model, and this page has no like-for-like result for Claude models on these exact test versions. Rather than mix scores from different setups, it shows only Gemma 4's. For Claude's results, see Anthropic's own publications.

From Google's model card. All sizes and tests are on the benchmarks page.

Use them together

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.

Your computer Claude Codethe agent Ollamalocalhost:11434 Gemma 4on your GPU Requests go out in blue, edits and answers come back in green Model requests stay on your machine
Claude Code's interface, Gemma 4's brain, your hardware.
Not supported by Anthropic. Anthropic's documentation says it "doesn't support routing Claude Code to non-Claude models". This setup comes from Ollama's side. If something breaks, it is yours to fix.
# 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.

Trade-offs

What works and what stops working

Ollama covers the core of the API Claude Code relies on, but not all of it.

FeatureWith OllamaWhat it means for you
Messages, streaming, system promptsWorksThe basic conversation loop runs
Tool callingWorksFile reads, edits and shell commands can happen
ImagesWorksScreenshots can be read
ThinkingWorksReasoning before answering is available
Prompt cachingNot supportedThe whole conversation is re-read every turn, so long sessions slow down
Forcing a specific toolNot supportedThe model decides which tool to use, or whether to use one
Token countingNot supportedUsage and context figures may be estimates
PDF input and citationsNot supportedConvert documents to text first
BatchesNot supportedNo 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.

Model choice

Which Gemma 4 size to put behind it

ModelOllama tagDownloadTau2Verdict
Gemma 4 26B A4Bgemma4:26b-a4b-it-qat16 GB68.2The practical pick: quick replies, fits a 24 GB GPU
Gemma 4 31Bgemma4:31b-it-qat19 GB76.9Best results, slower per token
Gemma 4 12Bgemma4:12b-it-qat7.2 GB69.0The realistic floor, for a 16 GB laptop
Gemma 4 E4B / E2Bgemma4:e4b · gemma4:e2b4 - 10 GB42.2 / 24.5Not 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.

Expectations

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
A lighter way to combine them. Keep Claude Code on Claude models and let it hand small, repetitive jobs to a local Gemma 4 with an ordinary shell command:
# 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.

FAQ

Gemma 4 and Claude Code questions

More answers on the full FAQ page.

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.

Top '