Running OpenClaw with Ollama - KDnuggets
-->
Join Newsletter
Introduction
You have successfully set up Ollama, pulled a capable model, run a few queries in the terminal, and it worked. The responses were sharp. The latency was real. The whole thing ran on your own hardware with no API key and no cloud.
Then you closed the terminal and walked away. The AI was gone. That is the gap OpenClaw fills. It is a personal AI assistant that runs on your hardware and stays running, bridging your local Ollama models to the messaging apps you already use: WhatsApp, Telegram, Slack, Discord, iMessage.
OpenClaw was created by Peter Steinberger, a macOS developer known for Apple tooling, and released in late 2025 under the name Clawdbot. The project passed 60,000 GitHub stars within weeks. As of Ollama 0.17, the entire setup collapses to a single command.
This article covers the full path from zero to a running private research assistant on Telegram, including configuring the context length correctly, connecting the channel, enabling web search, and deploying it headlessly in Docker.
What OpenClaw Is and How It Works
Before running any commands, it helps to understand what is actually happening under the hood, because the architecture explains several decisions you will make during setup.
Everything flows through a single daemon called the Gateway. It stays running in the background, holds your messaging connections open, and coordinates the AI agent. When you send a message from WhatsApp or Telegram, here is the actual sequence: your text arrives through the messaging platform's protocol (WhatsApp uses Baileys, Telegram uses the Bot API), travels to the Gateway, which routes it to your model via Ollama's local API, and delivers the response back through the same channel. You see a reply in the messaging app. Nothing else happens on your device visibly.
This three-layer design is what makes OpenClaw different from just running a chatbot in a terminal:
The messaging layer is the channel you send messages through: your phone, a desktop Telegram client, a Slack workspace. You do not need to be at the machine running Ollama. You just need to be connected to the messaging service.
The Gateway daemon is the coordination layer. It persists even when you are not actively using it, holds connections open, and manages multi-step agent tasks. This is what makes OpenClaw useful, rather than just interactive; tasks that take multiple tool calls can run in the background and deliver results when complete.
The model layer is Ollama. This can be a fully local model running on your GPU, or a cloud-backed model routed through Ollama's cloud service. The Gateway does not care which; it talks to Ollama's API either way.
One naming note worth covering upfront: OpenClaw was previously known as Moltbot and, before that, Clawdbot. It was renamed in early 2026. All old command aliases still work: ollama launch clawdbot still functions, so nothing breaks if you have those stored in scripts or documentation.
System Requirements and Prerequisites
The 64k context window requirement shapes everything else in your hardware and model selection decisions, so understand this before choosing a model.
Ollama defaults to context lengths based on available VRAM: under 24 GB gets 4k context, 24–48 GB gets 32k, and 48 GB or more gets 256k. The default for most consumer hardware is 4k, which is not enough for an agent doing multi-step tasks. You will need to set context explicitly, which the next section covers.
Hardware requirements:
Feature Minimum Recommended
OS macOS 12+, Linux, Windows (Windows Subsystem for Linux, WSL) macOS 14+, Ubuntu 22.04+
RAM 16 GB 32 GB
GPU VRAM (local model) 25 GB (for qwen3-coder or glm-4.7-flash) 48 GB+
GPU VRAM (cloud model) None, runs on Ollama's cloud GPU optional
Disk 5 GB (OpenClaw + deps) 30 GB+ if pulling local models
Software prerequisites:
Ollama 0.17 or later is required; this is the version that introduced ollama launch. Check your version with ollama --version and download the latest from ollama.com/download if needed.
Node.js 18 or later is required because OpenClaw installs via npm. Ollama detects and prompts for this automatically, but it is worth having it installed before you start. Download from nodejs.org if needed.
An Ollama account is required for cloud models and for web search on local models. Create one at ollama.com and sign in with:
ollama signin
Model recommendations:
Model Type VRAM Best for
kimi-k2.5:cloud Cloud None Multimodal reasoning and sub-agents
qwen3.5:cloud Cloud None Reasoning, coding, vision
minimax-m2.7:cloud Cloud None Fast productivity tasks
glm-5.1:cloud Cloud None Reasoning and code generation
qwen3-coder Local ~25 GB Coding tasks, full privacy
gemma4 Local ~16 GB Reasoning locally
Cloud models have full context length automatically and include web search support without any additional configuration. For most users starting out, kimi-k2.5:cloud is the right pick; it is free to start, handles agentic tasks well, and requires no VRAM.
One-Command Installation with ollama launch
With Ollama 0.17+, you do not manually install OpenClaw, configure a Gateway, or manage npm packages. Ollama handles the entire bootstrap sequence.
Open a terminal and run:
ollama launch openclaw
Or, to go directly to a specific model and skip the selector:
ollama launch openclaw --model kimi-k2.5:cloud
Ollama then handles five things automatically, in this order:
Install check: If OpenClaw is not already on your system, Ollama detects this and prompts you to install it via npm. Confirm, and it installs without you touching npm directly.
Security notice: Before anything else runs, OpenClaw displays a security warning: the agent has the ability to read files and execute actions on your machine when tools are enabled. This is not boilerplate. An agent with file access that receives a malicious instruction can cause real damage. Read it. Run OpenClaw in an isolated environment if you are not certain about what it can reach. The OpenClaw security documentation covers this in detail.
Model selector: A list of recommended models appears. Select one, or press Enter to use the model you specified with --model. The selector shows both cloud and local models with context window notes.
Onboarding: Ollama configures your provider, installs the Gateway daemon, sets the selected model as primary, and, if you chose a cloud model, enables OpenClaw's bundled Ollama web search automatically.
Gateway starts: The Gateway launches in the background. The OpenClaw terminal user interface (TUI) opens, and you can start chatting immediately.
If you only want to change the configuration without starting the Gateway and TUI:
Reconfigure without starting the agent
ollama launch openclaw --config
If the Gateway is already running when you do this, it restarts automatically to pick up the new settings. No manual restart needed.
Configuring Context Length for Agent Workloads
This is the step most tutorials skip, and it is the most common reason OpenClaw underperforms on real tasks.
The official docs state the minimum is 64k tokens, but understand what "minimum" means here. An agent doing a multi-step research task (web search → read page → extract information → summarize → respond) accumulates context across every step. At 64k, you have enough for a few turns with tool calls. For longer conversations or tasks with many tool invocations, you want more headroom. Cloud models are set to their maximum context length automatically and do not need this configuration.
For local models, set context length before launching:
Option 1: Environment variable (set it before starting Ollama)
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
For longer tasks on machines with enough VRAM, use more
OLLAMA_CONTEXT_LENGTH=131072 ollama serve
Option 2: Through the Ollama app
Open Ollama settings → Context Length → move the slider to 64000 or higher
Verify that the context was actually applied and that your model is not being offloaded to the CPU:
ollama ps
Look for output like this:
NAME ID SIZE PROCESSOR CONTEXT UNTIL qwen3-coder:latest a4f2cc91b3e1 28.1 GB 100% GPU 65536 5 minutes from now
Two things to check: PROCESSOR should show 100% GPU. If it shows a split like 40% GPU / 60% CPU, the model is being offloaded, and performance will be significantly degraded. CONTEXT should show 65536 or higher. If it shows 4096, your environment variable did not take effect. Make sure you started ollama serve in the same shell session where you set the variable.
If you cannot fit the full 64k in VRAM, use a cloud model instead of compromising on context. The agent needs the context more than it needs local inference.
Connecting a Messaging Channel
Once the Gateway is running, you connect your messaging platform with:
openclaw configure --section channels
This opens an interactive selector listing WhatsApp, Telegram, Slack, Discord, and iMessage. The setup steps differ per platform. Telegram is the cleanest starting point for developers. It requires no phone number linking and uses a proper bot token rather than emulating a personal account.
// Setting Up Telegram
Step 1: Create a bot with BotFather
Open Telegram and search for @BotFather. Send /newbot, choose a name (this is the display name), then choose a username (must end in bot, e.g. my_openclaw_bot). BotFather returns a token that looks like:
1234567890:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Copy this token. You will not be shown it again. If you lose it, you can generate a new one with /token.
Step 2: Paste the token into OpenClaw
In the openclaw configure --section channels menu, select Telegram, then paste the bot token when prompted.
Step 3: Select "Finished" to save
After configuring, select Finished in the configurator. This is required. Exiting without selecting Finished discards your configuration.
Step 4: Find your bot on Telegram and start a conversation
Search for your bot's username in Telegram. Send /start. The Gateway handles the first connection and the bot begins responding.
For WhatsApp, the process uses the Baileys protocol, which means you scan a QR code in the OpenClaw TUI to link your WhatsApp account. This works, but it links your actual WhatsApp account rather than creating a separate bot account. Be aware of that before proceeding.
For Slack and Discord, you will need to create an app in each platform's developer portal and supply the bot token and channel IDs. The OpenClaw configurator walks through the required fields for each.
The Real-World Project: Private Research Assistant on Telegram
Here is the full project this article has been building toward. A private Telegram bot that:
Answers questions using your local or cloud model
Searches the web for live information using Ollama's built-in web search
Fetches and summarizes documents and URLs you send it
Handles multi-step research tasks with no data leaving your machine (when using a local model)
Once your Telegram channel is connected and the Gateway is running, this is already functional without any additional code. OpenClaw handles the agent loop natively. The configuration choices you make are what shape the experience.
// Enabling Web Search
If you launched with a cloud model, Ollama installs the web search plugin automatically. You can verify it is active by asking your bot a question that requires current information: "What did Anthropic announce this week?" A properly configured bot with web search will search and return a cited answer. Without web search, it will answer from training data or say it does not know.
For local models, web search requires ollama signin first, then:
openclaw configure --section web
This enables the bundled Ollama web_search provider, which routes searches through Ollama's web search API using your account credentials.
// W
[truncated for AI cost control]