How to Set Up Gemma 4 in OpenClaw on Mac Mini
Build the ultimate budget-friendly local AI assistant: Gemma 4 running through OpenClaw on a Mac Mini. Step-by-step setup guide covering Ollama integration, OpenClaw configuration, multi-channel access, and cost comparison with cloud APIs.
Here's a thought experiment: what if you could have an AI assistant as capable as the ones behind paid API subscriptions — but running entirely on a $600 box on your desk, with unlimited tokens, zero monthly fees, and complete privacy?
That's not hypothetical anymore. A Mac Mini M4 with 24 GB of unified memory, Gemma 4's 26B MoE model, and OpenClaw as the agent framework gets you there. This guide shows you exactly how to set it up.
The Cost Math
Let's be honest about why this matters. Cloud API pricing for frontier models typically runs $3–15 per million tokens. A developer using an AI assistant heavily might burn through 10–50 million tokens per month. That's $30–750/month, or $360–9,000/year — ongoing, forever.
Now compare:
| Cloud API | Mac Mini + Gemma 4 | |
|---|---|---|
| Upfront cost | $0 | ~$600–800 (Mac Mini M4, 24 GB) |
| Monthly cost | $30–750+ | ~$5 (electricity) |
| Year 1 total | $360–9,000 | ~$660–860 |
| Year 2 total | $720–18,000 | ~$60 more |
| Token limit | Pay per token | Unlimited |
| Privacy | Data sent to cloud | Everything stays local |
| Offline | No | Yes |
The Mac Mini pays for itself within the first few months for most developers. After that, every token is free.
What Is OpenClaw?
OpenClaw is a free, open-source AI agent framework that runs on your own machine. Unlike simple chat interfaces, OpenClaw functions as a full-featured personal AI assistant that can:
- Run terminal commands and automate workflows
- Read and edit files on your system
- Access a library of 3,500+ community-built skills and plugins
- Connect through multiple channels — terminal, Telegram, WhatsApp, Discord, Slack, and more
- Work with both cloud APIs and local models through Ollama
Think of it as a self-hosted AI butler: it lives on your Mac Mini, it's always available, and it gets smarter as you add skills and configure it for your workflow.
What You'll Need
- Mac Mini M4 with at least 16 GB unified memory (24 GB recommended)
- macOS 14 Sonoma or newer
- Node.js 22+ (the OpenClaw installer handles this if missing)
- ~30 minutes for the initial setup
Choosing the Right Gemma 4 Model
Based on Google's official memory requirements at Q4_0 quantization:
| Mac Mini Config | Memory | Best Gemma 4 Fit | Why |
|---|---|---|---|
| M4 base | 16 GB | E4B (5 GB base) | Leaves plenty of room for macOS + OpenClaw |
| M4 (24 GB) | 24 GB | 26B A4B MoE (15.6 GB base) | The sweet spot — 26B quality at 4B speed |
| M4 (32 GB) | 32 GB | 26B A4B MoE (comfortable) | Room for long context and multitasking |
| M4 Pro (48 GB) | 48 GB | 31B dense (17.4 GB base) | Maximum quality with plenty of headroom |
The 26B A4B MoE on a 24 GB Mac Mini is the best value proposition in this lineup. It activates only 3.8 billion parameters per token (so it's fast), but draws on 26 billion total parameters (so it produces high-quality output). On Arena AI's leaderboard, it scores an Elo of 1441 — above models 10× its size.
For detailed memory planning, see our Hardware Requirements guide.
Step 1: Install Ollama and Pull Gemma 4
OpenClaw connects to models through Ollama's local API. Install Ollama first:
brew install --cask ollama
Launch Ollama (a llama icon appears in your menu bar), then pull your chosen Gemma 4 model:
# For 16 GB Mac Mini
ollama pull gemma4
# For 24+ GB Mac Mini (recommended)
ollama pull gemma4:26b
# For 48 GB Mac Mini M4 Pro
ollama pull gemma4:31b
Verify the download:
ollama list
Step 2: Install OpenClaw
Run the one-line installer:
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash
This script detects your system, installs Node.js if needed, downloads OpenClaw, and launches the onboarding wizard. During onboarding, when asked about your AI provider, select Ollama as the backend.
Alternatively, if you already have Node 22+:
npm install -g openclaw@latest
openclaw onboard --install-daemon
Verify the installation:
openclaw doctor
This checks your config, connectivity, and model availability — fix any issues it flags before proceeding.
Step 3: Configure OpenClaw for Gemma 4
There are two ways to connect Gemma 4: automatic discovery or manual configuration.
Option A: Auto-Discovery (Simplest)
If you ran openclaw onboard --auth-choice ollama during setup, OpenClaw auto-discovers models running in Ollama. Just set the environment variable:
export OLLAMA_API_KEY="ollama-local"
Add this to your ~/.zshrc so it persists:
echo 'export OLLAMA_API_KEY="ollama-local"' >> ~/.zshrc
source ~/.zshrc
Then check if OpenClaw sees Gemma 4:
openclaw models list
You should see your Gemma 4 model listed. Select it with:
/model gemma4:26b
Option B: Manual Configuration (Full Control)
For more control, edit your OpenClaw config file directly. Open ~/.openclaw/openclaw.json5:
{
models: {
providers: {
ollama: {
baseUrl: "http://localhost:11434/v1",
api: "openai-completions",
models: [
{
id: "gemma4:26b",
name: "Gemma 4 26B MoE",
contextWindow: 131072,
maxTokens: 8192
}
]
}
}
},
agents: {
defaults: {
model: {
primary: "ollama/gemma4:26b"
}
}
}
}
If you downloaded multiple variants, list them all:
models: [
{
id: "gemma4:latest",
name: "Gemma 4 E4B",
contextWindow: 131072,
maxTokens: 8192
},
{
id: "gemma4:26b",
name: "Gemma 4 26B MoE",
contextWindow: 262144,
maxTokens: 8192
}
]
Note: When manually defining the
models.providers.ollamablock, auto-discovery is turned off. Make sure to list all models you want to use.
Step 4: Verify and Start Using
Quick Test from Terminal
openclaw chat
This opens an interactive chat session. Try a few prompts:
- "List all files in the current directory that were modified today" — tests system command execution
- "Read package.json and summarize the dependencies" — tests file reading
- "Write a shell script that backs up my Documents folder to an external drive" — tests code generation and file writing
Run a One-Off Task
openclaw run "Create a Python script that monitors CPU temperature and logs it every 30 seconds"
OpenClaw generates the script, saves it, and can even make it executable — all using Gemma 4 running on your Mac Mini.
Optimizing for Daily Use
Keep the Model Loaded
Ollama unloads models after 5 minutes of inactivity by default. On a dedicated Mac Mini, you want the model always ready:
echo 'export OLLAMA_KEEP_ALIVE="-1"' >> ~/.zshrc
Increase the Context Window
A larger context window lets the model consider more information per request. For coding and document analysis:
echo 'export OLLAMA_CONTEXT_LENGTH=64000' >> ~/.zshrc
Launch Ollama at Login
Go to System Settings > General > Login Items and add Ollama. This ensures the model server starts automatically whenever your Mac Mini reboots.
Install the Daemon
OpenClaw's daemon keeps the agent running in the background:
openclaw onboard --install-daemon
With both the Ollama server and OpenClaw daemon running at startup, your AI assistant is ready the moment your Mac Mini boots up.
Beyond the Terminal: Multi-Channel Access
One of OpenClaw's unique features is multi-channel access. Your Gemma 4 assistant isn't limited to the terminal — you can reach it through messaging platforms:
Telegram — Chat with your assistant from your phone, anywhere. Ask it to check server status, run scripts, or answer questions about your codebase — all processed locally on your Mac Mini at home.
Discord / Slack — Set up a channel in your team server where the bot responds using your local Gemma 4. No data leaves your network.
WhatsApp / Signal — Personal AI assistant in your pocket, running on your own hardware.
Configure channels through the OpenClaw onboarding wizard or via the config file. Each message is routed to Gemma 4 on your Mac Mini, processed locally, and the response is sent back through the same channel.
This means you can be at a coffee shop, send a message to your Telegram bot, and have it execute tasks on your home Mac Mini — all powered by your local Gemma 4 model.
Troubleshooting
"No models found" in OpenClaw
Make sure Ollama is running (ollama serve) and the OLLAMA_API_KEY environment variable is set. Then run openclaw models list again.
Slow responses
If inference feels sluggish, check if the model is running on GPU:
ollama ps
On Apple Silicon, Ollama uses Metal GPU acceleration automatically. If your Mac Mini has 16 GB and you're running the 26B model, memory pressure might cause slowdowns — try the E4B instead or close memory-hungry apps.
Model not using tools correctly
Gemma 4's function calling works best with the larger variants (26B and 31B). The E4B model may sometimes struggle with complex multi-step tool use. If you're seeing issues, consider upgrading to the 26B MoE.
If streaming causes garbled tool calls, disable it in your config:
{
agents: {
defaults: {
models: {
"ollama/gemma4:26b": {
streaming: false
}
}
}
}
}
What This Setup Gives You
Take a step back and consider what you've built:
- A personal AI assistant that runs 24/7 on a compact, silent, low-power device
- Unlimited tokens — ask it a thousand questions a day, generate a thousand code files, no bill at the end of the month
- Complete privacy — your code, your documents, your conversations never leave your local network
- Offline capability — works without internet after the initial model download
- Multi-device access — reach it from your laptop, phone, or any messaging app
- Open source stack — Gemma 4 (Apache 2.0) + OpenClaw (open source) + Ollama (open source). No vendor lock-in
A year ago, this level of AI capability required a $200/month API subscription and a constant internet connection. Now it runs on a Mac Mini on your desk.
What's Next?
- Explore OpenClaw skills — browse the 3,500+ community plugins to extend your assistant's capabilities
- Fine-tune Gemma 4 — train the model on your own codebase or domain for even better results
- Try different models — swap between Gemma 4 variants to find the best speed/quality balance for your workflow
- Check our other guides — Run Gemma 4 with Ollama for a simpler setup, or Benchmarks to understand model capabilities
The era of personal AI servers isn't coming — it's already here. And it starts at $600.