If the phrase “OpenClaw local models setup running completely offline” landed you here, you probably have two goals: keep user data in-house and stop paying per-token to OpenAI. This guide documents the exact steps I use to run OpenClaw against locally hosted Llama 3, Mistral, and Mixtral models via Ollama—no internet calls once the weights are downloaded, no monthly bills, and nothing leaves the box.
Why bother with local models?
The cloud APIs are convenient, but they leak three things:
- Cost: At roughly
$0.50 – $1.50per million input tokens, background agents chewing through logs get expensive fast. - Latency: 200 ms network hops feel okay for chat, painful for tight control-loop automations.
- Privacy/compliance: Legal, health, and finance teams still veto sending customer data to third-party LLM providers.
Running locally solves all three. The trade-off: weaker models (think GPT-3.5 level at best), more hardware tuning, and you babysit the stack yourself.
Hardware requirements and what actually matters
The internet disagrees on specs, so here’s what I measured with ollama run llama3 in a loop:
- RAM: 16 GB bare minimum for 7 B parameter models. 32 GB gives headroom for OpenClaw, a browser, and Mongo.
- GPU (optional but huge win): Any 8 GB VRAM NVIDIA card halves latency versus CPU. FP16 works fine; you don’t need tensor cores.
- Disk: 15 GB per quantized 7 B model, 40 GB for 70 B. Use SSD—Ollama memory-maps weights on load.
- CPU: 8 logical cores or more. Apple Silicon is excellent; Intel i5 11-series is okay.
If you’re on a headless homelab server, add a swap file twice your RAM and you’re less likely to OOM during first-run quantization.
Step 1 – Install Ollama (the local model runtime)
macOS
Homebrew is the shortest path:
brew install ollama
ollama serve &
Linux (Debian/Ubuntu)
Ollama ships a one-liner that adds the repo and installs a .deb:
curl -fsSL https://ollama.com/install.sh | sh
sudo systemctl enable --now ollama
Windows 11 WSL2
Use the Linux steps inside WSL2. GPU passthrough is still hit-or-miss; CPU works but is slower.
After install, verify HTTP health:
curl http://localhost:11434/api/tags
You should get an empty JSON list—no models yet, but the daemon is alive.
Step 2 – Download recommended models (Llama 3, Mistral, Mixtral)
Ollama’s naming is plain English. Pull the 8-bit quantized builds to keep RAM in check:
# Meta Llama 3 8B instruct
ollama pull llama3
# Mistral 7B (good for tool use)
ollama pull mistral
# Mixtral 8x7B (mixture of experts, needs 32 GB RAM or 8 GB VRAM)
ollama pull mixtral
Ollama stores weights under ~/.ollama/models. Once they finish, run a smoke test:
ollama run llama3 "Why does the sky look blue?"
Expect a ~2.5 s first token on CPU, ~800 ms on mid-range GPUs. Subsequent prompts warm-start faster because of caching.
Step 3 – Expose model endpoints in a way OpenClaw understands
OpenClaw speaks OpenAI-compatible HTTP by default. Ollama’s /v1/chat/completions intentionally mirrors that spec, so the bridge is just a port. No reverse proxy needed unless you want HTTPS.
Optional nginx TLS termination
# /etc/nginx/sites-enabled/ollama.conf
server {
listen 443 ssl;
server_name llm.lan;
ssl_certificate /etc/ssl/certs/llm-lan.pem;
ssl_certificate_key /etc/ssl/private/llm-lan.key;
location /v1/ {
proxy_pass http://127.0.0.1:11434/;
proxy_set_header Host $host;
proxy_set_header Connection "upgrade";
}
}
If you stay on plain HTTP inside the LAN, just remember to switch the scheme in OpenClaw’s config.
Step 4 – Configure OpenClaw to use the local Ollama backend
OpenClaw 3.6.0 introduced first-class llm blocks in gateway.config.js. Here is the minimal diff from a fresh npx openclaw init project:
// gateway.config.js
module.exports = {
// …other config…
llms: {
localOllama: {
provider: "openai",
url: "http://127.0.0.1:11434/v1",
models: {
default: {
// The Ollama model name
name: "llama3",
// Higher temperature helps tiny models sound less robotic
temperature: 0.7,
// 4k context is all Ollama exposes today
maxTokens: 2048
},
fast: { name: "mistral", temperature: 0.5 },
creative: { name: "mixtral", temperature: 0.9 }
}
}
},
defaultLlm: "localOllama.default"
};
Restart the gateway:
npm run gateway
Head to http://localhost:3000, open the playground, and ask your agent who the current ISS commander is. Watch ollama serve logs to verify the hit.
Step 5 – Model-specific prompts and memory footprints
Llama 3 and Mistral use the normal ChatML style system-assistant-user tokens. Mixtral is more finicky; you’ll get better coherence by forcing mixture_of_experts=true in the Ollama modelfile, but that bumps GPU memory to 12 GB and is unstable on CPU. I leave Mixtral for creative writing tasks where hallucinations don’t hurt.
Measured resident set sizes on Ubuntu 22.04, kernel 6.5:
- Llama 3 8B – 9.2 GB
- Mistral 7B – 8.8 GB
- Mixtral 8×7B – 23.4 GB (CPU), 7.5 GB (GPU-quantized)
That’s why 16 GB RAM is the floor. The whole model must fit, plus Node.js, plus your agent memory store.
Step 6 – Performance benchmarks and where it hurts
I ran three 512-token chat completions five times each on my desktop (Ryzen 5700X, RTX 3060 12 GB, 32 GB RAM):
- Llama 3: 15.2 tokens/s GPU, 4.1 tokens/s CPU
- Mistral: 17.8 tokens/s GPU, 4.3 tokens/s CPU
- Mixtral: 9.6 tokens/s GPU, 1.7 tokens/s CPU
GPT-4 Turbo in the same test averaged 38 tokens/s over fiber. So yes, local models are slower and dumber. But for control tasks (shell operations, calendar lookups, JSON parsing) they’re “good enough.”
Where they fail:
- Long-form reasoning beyond 2-3 chain-of-thought steps
- Precision code generation in obscure languages (Rust macros, HLSL)
- Multilingual output outside EN/FR/ES
For those, point OpenClaw to a paid API just for the heavy query and keep the rest local. Hybrid setups are cheap and keep most text private.
Cost comparison: numbers on the table
One-time costs to download models: your bandwidth bill. After that:
- Electricity: My watt-meter shows 110 W idle, 185 W generating 10 tokens/s on GPU. That’s $0.011/hour at $0.12/kWh.
- Hardware amortization: $400 used RTX 3060 over three years ≈ $11/month.
At 1 M tokens/day, local costs ~$15/month. GPT-4 Turbo at $10/1M input + $30/1M output would be $40/month. Break-even is easy if you’re high volume, not so if you’re casual.
Trade-offs and maintenance tips
- Updates: Ollama releases weekly; each bump re-quantizes models. Script it:
sudo apt update && sudo apt upgrade -y ollama
ollama pull --all # grabs new weights only if changed
- Disk pressure: Archive unused models with
ollama rm MODELNAME. - Monitoring: Expose
node --inspecton OpenClaw and usehtopfor runtime leaks. - Back-offs: Set
maxRetries=0in OpenClaw when local; retries hammer the same host and just slow everything.
Practical next step
Clone your agent repo, follow the five steps above, and time a full workflow (e.g., “summarize 50 lines of log then file a GitHub issue”). If latency or quality is unacceptable, mix in a cloud model selectively rather than scrapping local hosting entirely. The toggles are already in gateway.config.js; you can switch models per-tool. That’s usually all the privacy and cost control a small team needs.