Model providers
Using Ollama (Local LLMs) with OpenClaw
Browse more in Model providers.
All model providers guides →This guide walks you through configuring OpenClaw to use Ollama so you can run local LLMs (and optional Ollama cloud models) as first-class models in your agents. You will enable auto-discovery of local models, optionally point OpenClaw at a remote Ollama host, and wire up defaults and fallbacks.
By the end, your OpenClaw agents will talk to Ollama’s native `/api/chat` endpoint with streaming and tool calling working correctly.
Prerequisites
- ✓Ollama installed on your machine or server — install from https://ollama.com/download.
- ✓Ollama running and reachable on the default port `http://127.0.0.1:11434` or another host/port you control.
- ✓The OpenClaw CLI installed and working so you can run `openclaw onboard`, `openclaw config`, and `openclaw models` commands.
- ✓At least one Ollama model pulled locally (for example `gemma4`, `gpt-oss:20b`, or `llama3.3`) or access to Ollama cloud models via `ollama signin`.
Steps
- 1
Install and run Ollama
Start by installing Ollama and making sure the server is running, otherwise OpenClaw has nothing to talk to. You install from the Ollama site, then run the Ollama service so the native `/api/chat` and `/api/tags` endpoints are available on port 11434.
bashollama serve - 2
Pull local models and optionally sign in for cloud models
Pull at least one local model so OpenClaw has something to auto-discover, and sign in if you also want Ollama cloud models. 5:cloud` do not require a local pull, but local ones do.
bashollama pull gemma4 # or ollama pull gpt-oss:20b # or ollama pull llama3.3 ollama signin - 3
Run OpenClaw onboarding with Ollama
Use the OpenClaw onboarding wizard to wire up Ollama without hand-editing config. This step lets you choose between Local or Cloud + Local, sets the base URL, and can auto-pull a selected model if it is missing.
bashopenclaw onboard - 4
Automate onboarding in non-interactive environments
For CI or scripted setups, run onboarding in non-interactive mode so you can bake Ollama into your deployment. You can also pass a custom base URL and model ID when your Ollama server runs on another host or you want a specific default model.
bashopenclaw onboard --non-interactive \ --auth-choice ollama \ --accept-risk openclaw onboard --non-interactive \ --auth-choice ollama \ --custom-base-url "http://ollama-host:11434" \ --custom-model-id "qwen3.5:27b" \ --accept-risk - 5
Enable Ollama via environment variable for implicit discovery
If you prefer minimal config, enable Ollama by setting `OLLAMA_API_KEY` and let OpenClaw auto-discover models from your local instance. ollama` if you want this implicit discovery behavior.
bashexport OLLAMA_API_KEY="ollama-local" - 6
Configure Ollama explicitly when running on a remote host
When Ollama runs on another host or you want full control over model definitions, configure the provider explicitly. Use the native base URL without `/v1` so you keep native tool calling and streaming behavior.
json{ models: { providers: { ollama: { baseUrl: "http://ollama-host:11434", apiKey: "ollama-local", api: "ollama", models: [ { id: "gpt-oss:20b", name: "GPT-OSS 20B", reasoning: false, input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, contextWindow: 8192, maxTokens: 8192 * 10 } ] } } } } - 7
Set a custom base URL without defining models
If you only need to point OpenClaw at a different Ollama host and still rely on native behavior, use an explicit provider with `baseUrl` and `api`. This disables auto-discovery, so plan to define models manually if you need a catalog.
json{ models: { providers: { ollama: { apiKey: "ollama-local", baseUrl: "http://ollama-host:11434", // No /v1 - use native Ollama API URL api: "ollama", // Set explicitly to guarantee native tool-calling behavior }, }, }, } - 8
Choose default and fallback Ollama models for your agents
Once Ollama is wired up, configure which model your agents use by default and what they fall back to. This keeps your agents resilient if a model is missing or fails.
json{ agents: { defaults: { model: { primary: "ollama/gpt-oss:20b", fallbacks: ["ollama/llama3.3", "ollama/qwen2.5-coder:32b"], }, }, }, } - 9
Set the default Ollama model via CLI or config
Use the CLI to inspect available models and switch the active one, or hard-code the default in your config. This is useful when you want a specific local model like `gemma4` to be the primary for all agents.
bashopenclaw models list openclaw models set ollama/gemma4 { agents: { defaults: { model: { primary: "ollama/gemma4" }, }, }, } - 10
Enable Ollama Web Search as the web search provider
If you want your agents to call Ollama’s web search, configure it as the `web_search` provider. This uses your existing Ollama host, requires `ollama signin`, and stays key-free.
json{ tools: { web: { search: { provider: "ollama", }, }, }, } - 11
Use reasoning models with Ollama
For reasoning-style models, pull an Ollama model whose name matches the reasoning heuristic so OpenClaw treats it as reasoning-capable. This lets you experiment with models like `deepseek-r1` while keeping config simple.
bashollama pull deepseek-r1:32b - 12
Configure legacy OpenAI-compatible mode when required by a proxy
If you sit behind a proxy that only speaks OpenAI format, switch Ollama to OpenAI-compatible mode in OpenClaw. Be aware that tool calling is not reliable here and you may need to disable streaming or `injectNumCtxForOpenAICompat` depending on your upstream.
json{ models: { providers: { ollama: { baseUrl: "http://ollama-host:11434/v1", api: "openai-completions", injectNumCtxForOpenAICompat: true, // default: true apiKey: "ollama-local", models: [...] } } } } { models: { providers: { ollama: { baseUrl: "http://ollama-host:11434/v1", api: "openai-completions", injectNumCtxForOpenAICompat: false, apiKey: "ollama-local", models: [...] } } } }
Configuration
| Option | Description | Example |
|---|---|---|
| OLLAMA_API_KEY | Enables Ollama in OpenClaw and triggers implicit model discovery when no explicit `models.providers.ollama` entry is defined. | ollama-local |
| models.providers.ollama.apiKey | API key value OpenClaw uses for Ollama availability checks; any value works because Ollama does not require a real key. | ollama-local |
| models.providers.ollama.baseUrl | The Ollama host and port OpenClaw connects to; use the native URL without `/v1` for full tool calling and streaming support. | http://ollama-host:11434 |
| models.providers.ollama.api | Selects the Ollama API mode; use `ollama` for native `/api/chat` or `openai-completions` for the OpenAI-compatible `/v1` endpoint. | ollama |
| models.providers.ollama.models[0].id | The model ID in Ollama that OpenClaw should call when using this explicit model definition. | gpt-oss:20b |
| models.providers.ollama.models[0].contextWindow | Overrides the context window for an explicitly defined Ollama model. | 8192 |
| models.providers.ollama.models[0].maxTokens | Sets the maximum tokens OpenClaw will request for an explicitly defined Ollama model. | 8192 * 10 |
| agents.defaults.model.primary | The primary model OpenClaw agents use by default, including the `ollama/` provider prefix. | ollama/gemma4 |
| agents.defaults.model.fallbacks | An ordered list of fallback Ollama models OpenClaw uses if the primary model fails or is unavailable. | ["ollama/llama3.3", "ollama/qwen2.5-coder:32b"] |
| tools.web.search.provider | Selects Ollama as the provider for web search tools, using your configured Ollama host. | ollama |
| models.providers.ollama.injectNumCtxForOpenAICompat | Controls whether OpenClaw injects `options.num_ctx` when using `api: "openai-completions"` so Ollama does not fall back to a 4096 context window. | true |
Troubleshooting
Ollama not detected by OpenClaw (no Ollama models show up after setting OLLAMA_API_KEY).
This usually means Ollama is not running or the API is not reachable on the expected host/port. Start the Ollama server and verify that `/api/tags` responds before relying on auto-discovery.
ollama serve
curl http://localhost:11434/api/tagsNo models available in OpenClaw even though Ollama is running.
ollama`. Use `ollama list` to inspect what is installed and pull the models you want.
ollama list # See what's installed
ollama pull gemma4
ollama pull gpt-oss:20b
ollama pull llama3.3 # Or another modelConnection refused when OpenClaw tries to call Ollama.
A connection refused error means nothing is listening on the configured host/port. Check that the Ollama process is running and restart it if needed, then confirm your `baseUrl` matches where it is listening.
# Check if Ollama is running
ps aux | grep ollama
# Or restart Ollama
ollama serveFrequently asked questions
Powered by Mem0
Add persistent memory to OpenClaw
Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.