How to Integrate Ollama Models in Openclaw

Image
Table of contents: [Show]

Quick Start: Install Ollama

Ollama lets you run large language models locally. This guide shows you how to integrate Ollama models into Openclaw for private, self-hosted AI inference.

Before starting, ensure you have Openclaw deployed on Linux or your preferred platform. For other deployment options, check out our Fly.io deployment guide.

Ollama Openclaw Integration

Step 1: Install Ollama and Pull a Model

First, ensure you have Ollama installed from ollama.ai. Then, pull a tool-capable model from your terminal:

ollama pull llama3.3

or

ollama pull qwen2.5-coder:32b

Step 2: Configure Openclaw

To make an Ollama model your primary agent model, set it in your ~/.openclaw/openclaw.json configuration file:

{ "agents": { "defaults": { "model": { "primary": "ollama/llama3.3" } } } }

Step 3: Remote Ollama Configuration

Here is an example of an explicit remote configuration:

{ "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"], "contextWindow": 8192, "maxTokens": 81920 } ] } } } }

Best Practices and Troubleshooting

  • Local Only: Ollama runs entirely on your machine—no data leaves your network.
  • Model Size: Larger models need more RAM. llama3.3 requires ~16GB for optimal performance.
  • GPU Acceleration: Ollama automatically uses CUDA/Metal if available.
  • Restart Gateway: After editing openclaw.json, restart the gateway: openclaw gateway restart