Ollama
Ollama is a local LLM runtime that makes it easy to run open-source models on your machine. OpenClaw integrates with Ollama’s OpenAI-compatible API and can auto-discover tool-capable models when you opt in withOLLAMA_API_KEY (or an auth profile) and do not define an explicit models.providers.ollama entry.
Quick start
- Install Ollama: https://ollama.ai
- Pull a model:
- Enable Ollama for OpenClaw (any value works; Ollama doesn’t require a real key):
- Use Ollama models:
Model discovery (implicit provider)
When you setOLLAMA_API_KEY (or an auth profile) and do not define models.providers.ollama, OpenClaw discovers models from the local Ollama instance at http://127.0.0.1:11434:
- Queries
/api/tagsand/api/show - Keeps only models that report
toolscapability - Marks
reasoningwhen the model reportsthinking - Reads
contextWindowfrommodel_info["<arch>.context_length"]when available - Sets
maxTokensto 10× the context window - Sets all costs to
0
models.providers.ollama explicitly, auto-discovery is skipped and you must define models manually (see below).
Configuration
Basic setup (implicit discovery)
The simplest way to enable Ollama is via environment variable:Explicit setup (manual models)
Use explicit config when:- Ollama runs on another host/port.
- You want to force specific context windows or model lists.
- You want to include models that do not report tool support.
OLLAMA_API_KEY is set, you can omit apiKey in the provider entry and OpenClaw will fill it for availability checks.
Custom base URL (explicit config)
If Ollama is running on a different host or port (explicit config disables auto-discovery, so define models manually):Model selection
Once configured, all your Ollama models are available:Advanced
Reasoning models
OpenClaw marks models as reasoning-capable when Ollama reportsthinking in /api/show:
Model Costs
Ollama is free and runs locally, so all model costs are set to $0.Streaming Configuration
Due to a known issue in the underlying SDK with Ollama’s response format, streaming is disabled by default for Ollama models. This prevents corrupted responses when using tool-capable models. When streaming is disabled, responses are delivered all at once (non-streaming mode), which avoids the issue where interleaved content/reasoning deltas cause garbled output.Re-enable Streaming (Advanced)
If you want to re-enable streaming for Ollama (may cause issues with tool-capable models):Disable Streaming for Other Providers
You can also disable streaming for any provider if needed:Context windows
For auto-discovered models, OpenClaw uses the context window reported by Ollama when available, otherwise it defaults to8192. You can override contextWindow and maxTokens in explicit provider config.
Troubleshooting
Ollama not detected
Make sure Ollama is running and that you setOLLAMA_API_KEY (or an auth profile), and that you did not define an explicit models.providers.ollama entry:
No models available
OpenClaw only auto-discovers models that report tool support. If your model isn’t listed, either:- Pull a tool-capable model, or
- Define the model explicitly in
models.providers.ollama.
Connection refused
Check that Ollama is running on the correct port:Corrupted responses or tool names in output
If you see garbled responses containing tool names (likesessions_send, memory_get) or fragmented text when using Ollama models, this is due to an upstream SDK issue with streaming responses. This is fixed by default in the latest OpenClaw version by disabling streaming for Ollama models.
If you manually enabled streaming and experience this issue:
- Remove the
streaming: trueconfiguration from your Ollama model entries, or - Explicitly set
streaming: falsefor Ollama models (see Streaming Configuration)
See Also
- Model Providers - Overview of all providers
- Model Selection - How to choose models
- Configuration - Full config reference