
Local AI Models with Ollama & Data Sovereignty
This guide shows how to run a local AI model such as Gemma 4 with Ollama on your VPS or dedicated server and connect it to OpenClaw. Without cloud providers or external API keys, your data stays on your own server and no usage-based API costs apply.
Why go local? With cloud-based AI, your prompts are processed by an external provider. With Ollama + OpenClaw, your data stays on your server. Note: on servers without a GPU, local models run on the CPU and respond noticeably slower than cloud models. Plan for at least 16 GB of RAM for models in the size range of gemma4; models with tool support are required.
Install Ollama Engine
127.0.0.1:11434:gemma4 as the default local model; smaller alternatives are e.g. gemma4:e2b or qwen3.5:4b:Set the Context Window (Optional)
gemma4 support considerably more, and OpenClaw passes the context size to Ollama automatically. If you want to fix the context size, for example to limit memory usage, create a customized model variant:Select the Model in OpenClaw
openclaw models set ollama/gemma4:| Prompt | Input / Selection |
|---|---|
| Ollama mode | Local only |
| Select AI Provider | Ollama |
| Model Name | gemma4 (or gemma4-agent) |
| Base URL (without /v1) | http://127.0.0.1:11434 |
| API Key | not required locally |
Restart the Gateway & Test
Setup Complete
Your local model is now connected to OpenClaw. If you encounter memory issues, use a smaller model or a smaller context window and restart the Ollama service with systemctl restart ollama.
Next Step: Security