Thursday, July 9, 2026

Operating OpenClaw with Ollama – KDnuggets


 

Introduction

 
You have got efficiently arrange Ollama, pulled a succesful mannequin, run a couple of queries within the terminal, and it labored. The responses had been sharp. The latency was actual. The entire thing ran by yourself {hardware} with no API key and no cloud.

Then you definitely closed the terminal and walked away. The AI was gone. That’s the hole OpenClaw fills. It’s a private AI assistant that runs in your {hardware} and stays working, bridging your native Ollama fashions to the messaging apps you already use: WhatsApp, Telegram, Slack, Discord, iMessage.

OpenClaw was created by Peter Steinberger, a macOS developer identified for Apple tooling, and launched in late 2025 beneath the identify Clawdbot. The undertaking handed 60,000 GitHub stars inside weeks. As of Ollama 0.17, all the setup collapses to a single command.

This text covers the total path from zero to a working non-public analysis assistant on Telegram, together with configuring the context size accurately, connecting the channel, enabling internet search, and deploying it headlessly in Docker.

 

What OpenClaw Is and How It Works

 
Earlier than working any instructions, it helps to grasp what is definitely occurring beneath the hood, as a result of the structure explains a number of choices you’ll make throughout setup.
Every part flows via a single daemon referred to as the Gateway. It stays working within the background, holds your messaging connections open, and coordinates the AI agent. While you ship a message from WhatsApp or Telegram, right here is the precise sequence: your textual content arrives via the messaging platform’s protocol (WhatsApp makes use of Baileys, Telegram makes use of the Bot API), travels to the Gateway, which routes it to your mannequin by way of Ollama’s native API, and delivers the response again via the identical channel. You see a reply within the messaging app. Nothing else occurs in your machine visibly.

This three-layer design is what makes OpenClaw totally different from simply working a chatbot in a terminal:

  1. The messaging layer is the channel you ship messages via: your cellphone, a desktop Telegram shopper, a Slack workspace. You don’t want to be on the machine working Ollama. You simply have to be related to the messaging service.
  2. The Gateway daemon is the coordination layer. It persists even if you end up not actively utilizing it, holds connections open, and manages multi-step agent duties. That is what makes OpenClaw helpful, somewhat than simply interactive; duties that take a number of instrument calls can run within the background and ship outcomes when full.
  3. The mannequin layer is Ollama. This generally is a absolutely native mannequin working in your GPU, or a cloud-backed mannequin routed via Ollama’s cloud service. The Gateway doesn’t care which; it talks to Ollama’s API both means.

 
Architecture diagram showing the three-layer flow
 

One naming notice price overlaying upfront: OpenClaw was beforehand often known as Moltbot and, earlier than that, Clawdbot. It was renamed in early 2026. All outdated command aliases nonetheless work: ollama launch clawdbot nonetheless capabilities, so nothing breaks when you have these saved in scripts or documentation.

 

System Necessities and Conditions

 
The 64k context window requirement shapes all the things else in your {hardware} and mannequin choice choices, so perceive this earlier than selecting a mannequin.

Ollama defaults to context lengths primarily based on out there VRAM: beneath 24 GB will get 4k context, 24–48 GB will get 32k, and 48 GB or extra will get 256k. The default for many client {hardware} is 4k, which isn’t sufficient for an agent doing multi-step duties. You’ll need to set context explicitly, which the following part covers.

{Hardware} necessities:

 

Function Minimal Beneficial
OS macOS 12+, Linux, Home windows (Home windows Subsystem for Linux, WSL) macOS 14+, Ubuntu 22.04+
RAM 16 GB 32 GB
GPU VRAM (native mannequin) 25 GB (for qwen3-coder or glm-4.7-flash) 48 GB+
GPU VRAM (cloud mannequin) None, runs on Ollama’s cloud GPU non-compulsory
Disk 5 GB (OpenClaw + deps) 30 GB+ if pulling native fashions

 

Software program conditions:

  • Ollama 0.17 or later is required; that is the model that launched ollama launch. Verify your model with ollama --version and obtain the newest from ollama.com/obtain if wanted.
  • Node.js 18 or later is required as a result of OpenClaw installs by way of npm. Ollama detects and prompts for this mechanically, however it’s price having it put in earlier than you begin. Obtain from nodejs.org if wanted.
  • An Ollama account is required for cloud fashions and for internet search on native fashions. Create one at ollama.com and register with:

 

Mannequin suggestions:

 

 

Cloud fashions have full context size mechanically and embrace internet search assist with none further configuration. For many customers beginning out, kimi-k2.5:cloud is the proper choose; it’s free to begin, handles agentic duties properly, and requires no VRAM.

 

One-Command Set up with ollama launch

 
With Ollama 0.17+, you don’t manually set up OpenClaw, configure a Gateway, or handle npm packages. Ollama handles all the bootstrap sequence.

Open a terminal and run:

 

Or, to go on to a selected mannequin and skip the selector:

ollama launch openclaw --model kimi-k2.5:cloud

 

Ollama then handles 5 issues mechanically, on this order:

  1. Set up examine: If OpenClaw just isn’t already in your system, Ollama detects this and prompts you to put in it by way of npm. Verify, and it installs with out you touching npm straight.
  2. Safety discover: Earlier than the rest runs, OpenClaw shows a safety warning: the agent has the flexibility to learn recordsdata and execute actions in your machine when instruments are enabled. This isn’t boilerplate. An agent with file entry that receives a malicious instruction could cause actual harm. Learn it. Run OpenClaw in an remoted surroundings in case you are not sure about what it may possibly attain. The OpenClaw safety documentation covers this intimately.
  3. Mannequin selector: A listing of beneficial fashions seems. Choose one, or press Enter to make use of the mannequin you specified with --model. The selector reveals each cloud and native fashions with context window notes.
  4. Onboarding: Ollama configures your supplier, installs the Gateway daemon, units the chosen mannequin as main, and, in case you selected a cloud mannequin, permits OpenClaw’s bundled Ollama internet search mechanically.
  5. Gateway begins: The Gateway launches within the background. The OpenClaw terminal consumer interface (TUI) opens, and you can begin chatting instantly.

Should you solely need to change the configuration with out beginning the Gateway and TUI:

# Reconfigure with out beginning the agent
ollama launch openclaw --config

 

If the Gateway is already working if you do that, it restarts mechanically to select up the brand new settings. No handbook restart wanted.

 

Configuring Context Size for Agent Workloads

 
That is the step most tutorials skip, and it’s the most typical motive OpenClaw underperforms on actual duties.

The official docs state the minimal is 64k tokens, however perceive what “minimal” means right here. An agent doing a multi-step analysis activity (internet search → learn web page → extract data → summarize → reply) accumulates context throughout each step. At 64k, you have got sufficient for a couple of turns with instrument calls. For longer conversations or duties with many instrument invocations, you need extra headroom. Cloud fashions are set to their most context size mechanically and don’t want this configuration.

For native fashions, set context size earlier than launching:

# Choice 1: Atmosphere variable (set it earlier than beginning Ollama)
OLLAMA_CONTEXT_LENGTH=64000 ollama serve

# For longer duties on machines with sufficient VRAM, use extra
OLLAMA_CONTEXT_LENGTH=131072 ollama serve

# Choice 2: By means of the Ollama app
# Open Ollama settings → Context Size → transfer the slider to 64000 or greater

 

Confirm that the context was truly utilized and that your mannequin just isn’t being offloaded to the CPU:

 

Search for output like this:

NAME                  ID              SIZE      PROCESSOR    CONTEXT    UNTIL
qwen3-coder:newest    a4f2cc91b3e1    28.1 GB   100% GPU     65536      5 minutes from now

 

Two issues to examine: PROCESSOR ought to present 100% GPU. If it reveals a cut up like 40% GPU / 60% CPU, the mannequin is being offloaded, and efficiency might be considerably degraded. CONTEXT ought to present 65536 or greater. If it reveals 4096, your surroundings variable didn’t take impact. Ensure you began ollama serve in the identical shell session the place you set the variable.

Should you can not match the total 64k in VRAM, use a cloud mannequin as a substitute of compromising on context. The agent wants the context greater than it wants native inference.

 

Connecting a Messaging Channel

 
As soon as the Gateway is working, you join your messaging platform with:

openclaw configure --section channels

 

This opens an interactive selector itemizing WhatsApp, Telegram, Slack, Discord, and iMessage. The setup steps differ per platform. Telegram is the cleanest place to begin for builders. It requires no cellphone quantity linking and makes use of a correct bot token somewhat than emulating a private account.

 

// Setting Up Telegram

Step 1: Create a bot with BotFather
Open Telegram and seek for @BotFather. Ship /newbot, select a reputation (that is the show identify), then select a username (should finish in bot, e.g. my_openclaw_bot). BotFather returns a token that appears like:

1234567890:AAFxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

Copy this token. You’ll not be proven it once more. Should you lose it, you possibly can generate a brand new one with /token.

Step 2: Paste the token into OpenClaw
Within the openclaw configure --section channels menu, choose Telegram, then paste the bot token when prompted.

Step 3: Choose “Completed” to avoid wasting
After configuring, choose Completed within the configurator. That is required. Exiting with out choosing Completed discards your configuration.

Step 4: Discover your bot on Telegram and begin a dialog
Seek for your bot’s username in Telegram. Ship /begin. The Gateway handles the primary connection and the bot begins responding.

For WhatsApp, the method makes use of the Baileys protocol, which suggests you scan a QR code within the OpenClaw TUI to hyperlink your WhatsApp account. This works, however it hyperlinks your precise WhatsApp account somewhat than making a separate bot account. Pay attention to that earlier than continuing.

For Slack and Discord, you’ll need to create an app in every platform’s developer portal and provide the bot token and channel IDs. The OpenClaw configurator walks via the required fields for every.

 

The Actual-World Venture: Non-public Analysis Assistant on Telegram

 
Right here is the total undertaking this text has been constructing towards. A personal Telegram bot that:

  • Solutions questions utilizing your native or cloud mannequin
  • Searches the online for reside data utilizing Ollama’s built-in internet search
  • Fetches and summarizes paperwork and URLs you ship it
  • Handles multi-step analysis duties with no knowledge leaving your machine (when utilizing a neighborhood mannequin)

As soon as your Telegram channel is related and the Gateway is working, that is already practical with none further code. OpenClaw handles the agent loop natively. The configuration selections you make are what form the expertise.

 

// Enabling Net Search

Should you launched with a cloud mannequin, Ollama installs the online search plugin mechanically. You’ll be able to confirm it’s lively by asking your bot a query that requires present data: “What did Anthropic announce this week?” A correctly configured bot with internet search will search and return a cited reply. With out internet search, it’s going to reply from coaching knowledge or say it doesn’t know.

For native fashions, internet search requires ollama signin first, then:

openclaw configure --section internet

 

This permits the bundled Ollama web_search supplier, which routes searches via Ollama’s internet search API utilizing your account credentials.

 

// What a Multi-Step Job Appears Like within the TUI

Ship this to your Telegram bot:

Discover the three most-cited papers on transformer consideration revealed in 2025 and provides me a one-sentence abstract of every.

 

Within the OpenClaw TUI in your machine, you will note the agent’s instrument name log as it really works. One thing like:

[tool] web_search: "most cited transformer consideration papers 2025"
[tool] web_fetch: https://arxiv.org/...
[tool] web_fetch: https://paperswithcode.com/...
[reasoning] Recognized three papers: ...
[response] Sending to Telegram...

 

The duty completes in Telegram as a formatted message with the three papers, their quotation counts, and summaries, sometimes in 20–40 seconds relying in your mannequin and connection velocity.

That’s the core of what makes this setup genuinely helpful: multi-step agent duties that may require a browser, a number of searches, and handbook synthesis might be delegated out of your cellphone with a single message and return a synthesized reply when you do one thing else.

 

// The Python Script Method: Calling the Net Search API Immediately

If you wish to construct on prime of this setup programmatically, for instance, scheduling every day analysis summaries or piping outcomes right into a database, you possibly can name Ollama’s internet search API straight from Python utilizing the identical credentials OpenClaw makes use of:

# research_agent.py
# A minimal analysis agent utilizing Ollama's internet search + chat API.
# Conditions:
#   pip set up ollama
#   ollama signin (run as soon as in your terminal)
#   ollama pull qwen3.5:cloud  (or any tool-capable mannequin)
#
# Methods to run:
#   python research_agent.py "What are the newest developments in native LLMs?"

import sys
from ollama import chat, web_search, web_fetch

# ── Instrument registry ─────────────────────────────────────────────────────────────
# Map instrument names to precise callables so we will dispatch instrument calls from the mannequin.
AVAILABLE_TOOLS = {
    "web_search": web_search,
    "web_fetch":  web_fetch,
}

def run_research_agent(question: str, mannequin: str = "qwen3.5:cloud") -> str:
    """
    A multi-turn analysis agent that makes use of internet search and web page fetching
    to reply questions with up-to-date data.

    Args:
        question: The analysis query to reply
        mannequin: Ollama mannequin to make use of. Cloud fashions beneficial for 64k+ context.

    Returns:
        The agent's remaining synthesized reply as a string.
    """
    messages = [
        {
            "role": "system",
            "content": (
                "You are a research assistant. When answering questions that require "
                "current information, use the web_search tool to find relevant results, "
                "then use web_fetch to read the most promising pages before responding. "
                "Always cite your sources in the final answer."
            ),
        },
        {
            "role": "user",
            "content": query,
        },
    ]

    print(f"Question: {question}nModel: {mannequin}n{'─' * 60}")

    # ── Agentic loop ──────────────────────────────────────────────────────────
    # The loop continues so long as the mannequin is making instrument calls.
    # When the mannequin stops calling instruments and writes a remaining response, we break.

    whereas True:
        response = chat(
            mannequin=mannequin,
            messages=messages,
            instruments=[web_search, web_fetch],  # Cross the precise callables -- Ollama extracts the schema
            suppose=True,                      # Allow chain-of-thought earlier than instrument choices
        )

        # Present reasoning hint if current (suppose=True)
        if response.message.considering:
            print(f"[thinking] {response.message.considering[:200]}...")

        # Append the mannequin's response to message historical past
        messages.append(response.message)

        # If the mannequin made instrument calls, execute each and inject outcomes
        if response.message.tool_calls:
            for tool_call in response.message.tool_calls:
                tool_name = tool_call.perform.identify
                tool_fn   = AVAILABLE_TOOLS.get(tool_name)

                if not tool_fn:
                    # Instrument not discovered -- inform the mannequin so it may possibly regulate
                    print(f"[tool] {tool_name}: NOT FOUND")
                    messages.append({
                        "function":      "instrument",
                        "content material":   f"Instrument '{tool_name}' just isn't out there.",
                        "tool_name": tool_name,
                    })
                    proceed

                args   = tool_call.perform.arguments
                print(f"[tool] {tool_name}({args})")

                end result = tool_fn(**args)
                result_str = str(end result)
                print(f"[result] {result_str[:150]}...")

                # Truncate instrument outcomes to remain inside context funds.
                # At 64k context, ~8000 chars per result's a secure ceiling
                # for multi-step duties with a number of instrument calls.
                messages.append({
                    "function":      "instrument",
                    "content material":   result_str[:8000],
                    "tool_name": tool_name,
                })
        else:
            # No extra instrument calls -- the mannequin has a remaining reply
            final_answer = response.message.content material
            print(f"n{'─' * 60}nAnswer:n{final_answer}")
            return final_answer


# ── Entry level ───────────────────────────────────────────────────────────────

if __name__ == "__main__":
    question = sys.argv[1] if len(sys.argv) > 1 else "What are the newest developments in native LLMs?"
    run_research_agent(question)

 

Conditions:

pip set up ollama
ollama signin
ollama pull qwen3.5:cloud

 

Methods to run:

python research_agent.py "What are the three most-cited papers on transformer consideration revealed in 2025?"

 

Anticipated output:

Question: What are the three most-cited papers on transformer consideration revealed in 2025?
Mannequin: qwen3.5:cloud
────────────────────────────────────────────────────────────
[thinking] The consumer desires particular papers from 2025. I have to seek for current publications...
[tool] web_search({'question': 'most cited transformer consideration papers 2025', 'max_results': 5})
[result] outcomes=[WebSearchResult(content="..."), ...]...
[tool] web_fetch({'url': 'https://paperswithcode.com/...'})
[result] title="Papers With Code - Transformer Consideration..."...

────────────────────────────────────────────────────────────
Reply:
Listed below are three highly-cited transformer consideration papers from 2025:

1. **[Paper Title]** -- [Summary]. Cited 847 instances as of June 2026.
   Supply: arxiv.org/...

2. **[Paper Title]** -- [Summary]. Cited 623 instances.
   Supply: paperswithcode.com/...

3. **[Paper Title]** -- [Summary]. Cited 511 instances.
   Supply: semanticscholar.org/...

 

The instrument name truncation at 8,000 characters per result’s an important sensible element on this script. With out it, an extended internet web page fetched in a single instrument name can eat 20k–40k tokens of your context funds in a single step, leaving inadequate room for subsequent instrument calls and the ultimate synthesis. Truncate aggressively and depend on the mannequin’s capability to work with essentially the most related portion.

 

Non-Interactive and Headless Deployment

 
For manufacturing use, a machine that runs the agent 24/7, or a deployment in Docker, the interactive TUI is in the way in which. The --yes flag removes it completely:

ollama launch openclaw --model kimi-k2.5:cloud --yes

 

The --yes flag auto-pulls the mannequin, skips all interactive selectors, and begins the Gateway instantly. It requires --model to be specified explicitly. The flag has no approach to guess a mannequin with out the selector.

Dockerfile for a headless OpenClaw server:

# Dockerfile
# Runs Ollama + OpenClaw as a headless agent service.
# Construct: docker construct -t openclaw-agent .
# Run:   docker run -d --gpus all --env-file .env openclaw-agent
#
# Conditions for the construct machine:
#   - Docker with nvidia-container-toolkit (for GPU passthrough)
#   - A .env file with OLLAMA_API_KEY and channel credentials

FROM ubuntu:22.04

# ── System dependencies ────────────────────────────────────────────────────────
# Ubuntu 22.04's default apt repo ships Node.js 12.x, which doesn't meet
# OpenClaw's Node.js 18+ requirement, so Node.js 18 is put in by way of NodeSource.
RUN apt-get replace && apt-get set up -y curl 
    && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - 
    && apt-get set up -y nodejs 
    && rm -rf /var/lib/apt/lists/*

# ── Set up Ollama ─────────────────────────────────────────────────────────────
RUN curl -fsSL https://ollama.com/set up.sh | sh

# ── Set up OpenClaw by way of npm ───────────────────────────────────────────────────
# Set up globally so the `openclaw` binary is in PATH
RUN npm set up -g openclaw

# ── Set context size for agent workloads ─────────────────────────────────────
# 64000 is the minimal. Enhance in case your GPU has VRAM headroom.
ENV OLLAMA_CONTEXT_LENGTH=64000

# ── Startup script ─────────────────────────────────────────────────────────────
# 1. Begin the Ollama server within the background
# 2. Look ahead to it to be prepared
# 3. Launch OpenClaw headlessly with the required cloud mannequin
COPY begin.sh /begin.sh
RUN chmod +x /begin.sh

EXPOSE 11434

CMD ["/start.sh"]

# begin.sh -- runs alongside the Dockerfile above

#!/bin/bash
set -e

# Begin the Ollama server within the background
ollama serve &
OLLAMA_PID=$!

# Wait till Ollama's API is responding (as much as 30 seconds)
echo "Ready for Ollama to begin..."
for i in $(seq 1 30); do
    if curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
        echo "Ollama prepared."
        break
    fi
    sleep 1
completed

# Launch OpenClaw headlessly -- --yes skips all interactive prompts
# OLLAMA_MODEL needs to be set in your .env file or docker run -e flag
ollama launch openclaw 
    --model "${OLLAMA_MODEL:-kimi-k2.5:cloud}" 
    --yes

# Hold the container alive and comply with OpenClaw's logs
wait $OLLAMA_PID

 

Construct and run:

# Create a .env file along with your credentials
cat > .env << EOF
OLLAMA_MODEL=kimi-k2.5:cloud
OLLAMA_API_KEY=your_ollama_api_key
EOF

# Construct the picture
docker construct -t openclaw-agent .

# Run with GPU passthrough (requires nvidia-container-toolkit)
docker run -d 
    --gpus all 
    --env-file .env 
    --name openclaw 
    openclaw-agent

# Comply with logs
docker logs -f openclaw

 

For native fashions with out GPU passthrough, take away --gpus all and guarantee OLLAMA_MODEL factors to a cloud mannequin. The GPU flag is just wanted when working native fashions that require VRAM.

Stopping and restarting the Gateway:

# Cease the Gateway cleanly (use this as a substitute of killing the method)
openclaw gateway cease

# The Gateway restarts mechanically if you run ollama launch once more
ollama launch openclaw --model kimi-k2.5:cloud --yes

 

 

Stopping the Gateway and Frequent Troubleshooting

 
Cease the Gateway cleanly when you could:

 

Utilizing Ctrl+C within the TUI works for the interactive session however could go away the Gateway daemon working. Use gateway cease to make sure it terminates.

Frequent points:

  • If messages are usually not being processed, examine that the Gateway is definitely working:
# Verify if the openclaw gateway course of is alive
pgrep -la openclaw

 

  • If the agent provides outdated solutions regardless of internet search being configured, confirm your Ollama account is signed in:

 

  • Should you see context size exceeded errors within the TUI log, your context window is just too small for the duty. Enhance OLLAMA_CONTEXT_LENGTH and restart ollama serve earlier than relaunching OpenClaw.
  • If the mannequin is being partially offloaded to CPU (seen in ollama ps as a cut up proportion), both cut back context size, swap to a smaller mannequin, or transfer to a cloud mannequin. CPU offloading works however will make multi-step duties noticeably sluggish.

 

Conclusion

 
OpenClaw and Ollama collectively shut the hole between “AI that works in a terminal” and “AI that works wherever you might be.” The Gateway runs within the background. Your messaging app turns into the interface. A single command units up all the stack.

The sensible worth reveals up rapidly: multi-step analysis duties you’ll usually spend 20 minutes doing manually full within the background when you are doing one thing else, delivered as a formatted message to your cellphone. File duties, calendar administration, and inbox processing are all increasing quickly, and OpenClaw’s talent library is rising alongside them, because the group builds integrations on prime of the Gateway structure.

For customers who care about the place their knowledge goes, the native mannequin path is straightforward: a succesful mannequin, 25 GB of VRAM, and one context-length configuration ship a completely non-public agent with no cloud dependency in any respect. For customers who need the simplest potential begin, a cloud mannequin is one command away.

Both path ends on the similar place: an AI assistant that solutions your messages, does your analysis, and runs on infrastructure you management.

 

// Assets

 
 

Shittu Olumide is a software program engineer and technical author captivated with leveraging cutting-edge applied sciences to craft compelling narratives, with a eager eye for element and a knack for simplifying complicated ideas. You too can discover Shittu on Twitter.



Related Articles

Latest Articles