Running OpenClaw Locally with Ollama: Private, Fast, and Free AI
OpenClaw is designed to be model-agnostic. While cloud providers like OpenAI and Anthropic offer incredible performance, there are compelling reasons to bring your AI home: privacy, latency, cost, and offline capability.
With the rise of powerful open-weight models like Llama 3, Qwen 2.5, and DeepSeek, running a capable agent on your laptop is no longer a science project—it's a practical reality.
In this guide, we'll show you how to connect OpenClaw to Ollama, the easiest way to run local LLMs.
Why Go Local?
- Privacy First: Your data never leaves your machine. Perfect for processing sensitive documents, personal journals, or proprietary code.
- Zero API Costs: Run your agent 24/7 without worrying about a surprise bill at the end of the month.
- Offline Capability: Your agent works even when the internet is down (provided it doesn't need web search!).
- Low Latency: No network round-trips. Responses feel snappy, especially for smaller models.
Step 1: Install Ollama
First, you need the runtime. Download Ollama from ollama.ai. It supports macOS, Linux, and Windows.
Once installed, pull a model. We recommend Llama 3.3 for general use or Qwen 2.5 Coder for programming tasks.
# General purpose assistant
ollama pull llama3.3
# Coding specialist
ollama pull qwen2.5-coder:32b
# Reasoning model (great for complex logic)
ollama pull deepseek-r1:32b
Verify it's running:
ollama list
Step 2: Connect OpenClaw
OpenClaw has built-in support for Ollama. The easiest way to connect is via environment variables or your config file.
Option A: The Quick Env Var
If you just want to test it out, set the OLLAMA_API_KEY environment variable. OpenClaw will automatically discover any tool-capable models you have installed.
export OLLAMA_API_KEY="ollama-local"
openclaw gateway start
Option B: The Config File (Recommended)
For a permanent setup, edit your openclaw.json (usually in ~/.openclaw/ or your workspace root).
{
models: {
providers: {
ollama: {
// Point to your local instance
baseUrl: "http://127.0.0.1:11434/v1",
apiKey: "ollama-local", // Any string works
api: "openai-completions",
// Explicitly list models if auto-discovery isn't working
models: [
{
id: "llama3.3",
name: "Llama 3.3 (Local)",
contextWindow: 8192,
maxTokens: 4096,
cost: { input: 0, output: 0 }
}
]
}
}
}
}
Step 3: Select Your Model
Now, tell your agent to use the local model.
{
agents: {
defaults: {
model: {
primary: "ollama/llama3.3",
// Fallback to a cloud model if needed
fallback: ["anthropic/claude-3-5-sonnet"]
}
}
}
}
Restart your gateway:
openclaw gateway restart
Auto-Discovery Magic
One of OpenClaw's coolest features is Ollama Auto-Discovery.
If you define OLLAMA_API_KEY but don't manually list models in the config, OpenClaw will query your local Ollama instance at startup. It filters for models that support tools/function calling and automatically registers them.
This means you can ollama pull mistral in your terminal, restart OpenClaw, and immediately use model: "ollama/mistral" without touching a config file.
Performance Tips
- Context Window: Local models often have smaller effective context windows than cloud giants. If you hit limits, try a model with a larger context (like
mistral-nemoorqwen2.5). - Hardware: You'll need RAM. A 7B model needs ~4GB, 8B needs ~6GB, and 70B needs ~40GB. If you're on a Mac with Apple Silicon, it flies. On CPU-only machines, it might be slow.
- Tools: Not all local models are great at using tools. Llama 3.3 and Qwen 2.5 are currently the best open-weights for tool use.
The Future is Hybrid
The most powerful setup is often hybrid: use a fast, free local model for routine tasks, summarization, and drafting, but configure OpenClaw to fall back to a "smart" cloud model (like GPT-4o or Claude 3.5 Sonnet) for complex reasoning or coding challenges.
With OpenClaw's model routing, you get the best of both worlds.
Start your local AI journey today. Download OpenClaw and take control of your intelligence stack.