Using OpenClaw with Ollama (Local LLMs)
Run OpenClaw entirely offline using Ollama local LLMs. 100% private, zero API costs. Supports NVIDIA (CUDA), Apple Silicon (Metal), and AMD (ROCm) GPU acceleration.
Prerequisites
- OpenClaw v1.0.0 or later installed (Installation Guide)
- At least 8 GB RAM for 7B models; 16 GB for 13B models
- A supported OS: Linux, macOS (Apple Silicon or Intel), or Windows (with WSL2)
- Optional: NVIDIA GPU with CUDA for faster inference
Step 1: Install Ollama
macOS / Linux
curl -fsSL https://ollama.com/install.sh | shWindows
Download the installer from ollama.com/download and run it. Ollama starts automatically as a background service.
Verify Ollama is Running
ollama --version
curl http://localhost:11434/api/tagsStep 2: Pull Models
# Pull popular models
ollama pull llama3.2 # Meta's Llama 3.2 (3B, fast)
ollama pull mistral # Mistral 7B (balanced)
ollama pull codellama # Code-focused Llama
ollama pull qwen2.5-coder # Alibaba coding model
# List downloaded models
ollama listStep 3: Configure OpenClaw
openclaw config set provider ollama
openclaw config set ollama.model llama3.2
openclaw config set ollama.host http://localhost:11434# config.yaml
provider: ollama
ollama:
host: http://localhost:11434
model: llama3.2
temperature: 0.7
num_ctx: 8192Step 4: Test
openclaw run "What is 2+2?" --provider ollama
openclaw run "Write a Python hello world" --provider ollama --model codellamaGPU Acceleration
NVIDIA (CUDA)
# Install CUDA drivers then verify Ollama uses GPU
ollama run llama3.2
# Look for "GPU" in Ollama's log outputApple Silicon (Metal)
Ollama automatically uses Metal on M1/M2/M3 Macs. No configuration needed.
AMD (ROCm)
ROCM_PATH=/opt/rocm ollama serveCustom Modelfile
Create a custom model with a system prompt baked in:
FROM llama3.2
SYSTEM """
You are a helpful AI assistant integrated with OpenClaw.
Always respond with structured, actionable output.
When writing code, always include error handling.
"""
PARAMETER temperature 0.3
PARAMETER num_ctx 8192ollama create openclaw-custom -f Modelfile
openclaw config set ollama.model openclaw-customHardware Requirements
Ollama supports GPU-accelerated inference and runs on CPU as a fallback. The table below shows approximate RAM requirements per model size:
| Model Size | Min RAM (CPU) | Recommended RAM | GPU VRAM | Example Models |
|---|---|---|---|---|
| 3B parameters | 4 GB | 8 GB | 4 GB | llama3.2, phi3-mini |
| 7B parameters | 8 GB | 16 GB | 6–8 GB | mistral, llama3, gemma7b |
| 13B parameters | 16 GB | 32 GB | 10–12 GB | llama2-13b, vicuna-13b |
| 34B parameters | 32 GB | 64 GB | 24 GB | codellama-34b |
| 70B parameters | 64 GB | 128 GB | 48 GB+ | llama3-70b, mixtral |
Performance Tuning
Increase Context Window
# Larger context = more memory, but enables longer documents
ollama:
num_ctx: 16384 # default: 2048
num_gpu: 1 # GPU layers to offload (higher = faster, more VRAM)
num_thread: 8 # CPU threads for inferenceRun Multiple Models Concurrently
# Keep multiple models warm in memory
OLLAMA_MAX_LOADED_MODELS=3 ollama serveBenchmark a Model
time ollama run mistral "Write a 500-word essay on AI"Switching Between Local and Cloud Models
OpenClaw supports routing tasks between local (Ollama) and cloud (OpenAI, Claude) models based on task type or flag:
# Default: use local Ollama
openclaw run "Draft a short email"
# Override per-run to use cloud model
openclaw run "Analyze this 150-page legal PDF" --provider claude
openclaw run "Generate production code" --provider openai
# Define routing rules in config
# config.yaml
routing:
default: ollama
fallback: openai # use cloud if local fails
rules:
- pattern: "*.legal*"
provider: claude
- pattern: "*production*"
provider: openaiLM Studio as Alternative
LM Studio is a GUI application for running local LLMs. It exposes an OpenAI-compatible API on port 1234, which OpenClaw can connect to:
# config.yaml — connect OpenClaw to LM Studio
provider: openai
openai:
api_base: http://localhost:1234/v1
api_key: lm-studio # any non-empty string
model: local-model # name shown in LM StudioLM Studio is a great choice for Windows users who prefer a visual interface over command-line model management.
Building Private, Air-Gapped Automation
Ollama + OpenClaw is the only setup that works completely offline. Use cases include:
- Corporate environments where data cannot leave the network
- Medical / legal document processing without data exposure
- Development on flights or remote locations without internet
# Disable all external requests in OpenClaw config
# config.yaml
privacy:
offline_mode: true
disable_telemetry: true
disable_update_checks: true
# Run a fully offline task
openclaw run "Analyze /data/contracts/*.pdf and extract key clauses" --offlineTroubleshooting
| Problem | Cause | Fix |
|---|---|---|
| Connection refused on port 11434 | Ollama service not running | Run ollama serve or check system services |
| Model not found | Model not pulled yet | Run ollama pull <model-name> |
| Out of memory (OOM) | Model too large for RAM/VRAM | Use a smaller model variant (e.g., 3B instead of 7B) |
| Slow inference (<5 tok/s) | CPU-only, no GPU | Install CUDA drivers or use Apple Silicon; set num_gpu |
| Context length exceeded | num_ctx too small | Increase num_ctx in config (e.g., 8192 or 16384) |
What's Next
- Local LLM configuration deep-dive — advanced context, quantization, and GPU settings
- Telegram Bot Integration — control Ollama-powered automation from your phone
- Building AI Pipelines — chain Ollama tasks into complex workflows
- LLM Integration Use Cases — real-world examples using local models