Friday, July 10, 2026
HomeArtificial IntelligenceOperating OpenClaw with Ollama - KDnuggets

Operating OpenClaw with Ollama – KDnuggets

Operating OpenClaw with Ollama – KDnuggets
 

Introduction

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

You then 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 operating, 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 title Clawdbot. The mission handed 60,000 GitHub stars inside weeks. As of Ollama 0.17, your complete setup collapses to a single command.

This text covers the complete path from zero to a operating personal 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 operating any instructions, it helps to know what is definitely taking place beneath the hood, as a result of the structure explains a number of selections you’ll make throughout setup.
Every thing flows by a single daemon known as the Gateway. It stays operating within the background, holds your messaging connections open, and coordinates the AI agent. Once you ship a message from WhatsApp or Telegram, right here is the precise sequence: your textual content arrives by 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 through Ollama’s native API, and delivers the response again by the identical channel. You see a reply within the messaging app. Nothing else occurs in your gadget visibly.

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

  1. The messaging layer is the channel you ship messages by: your telephone, a desktop Telegram shopper, a Slack workspace. You do not want to be on the machine operating Ollama. You simply have to be linked 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, relatively 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 totally native mannequin operating in your GPU, or a cloud-backed mannequin routed by Ollama’s cloud service. The Gateway doesn’t care which; it talks to Ollama’s API both approach.

 
Architecture diagram showing the three-layer flow
 

One naming notice value protecting upfront: OpenClaw was beforehand generally known as Moltbot and, earlier than that, Clawdbot. It was renamed in early 2026. All previous command aliases nonetheless work: ollama launch clawdbot nonetheless capabilities, so nothing breaks when you’ve got these saved in scripts or documentation.

 

System Necessities and Conditions

 
The 64k context window requirement shapes every thing else in your {hardware} and mannequin choice selections, so perceive this earlier than selecting a mannequin.

Ollama defaults to context lengths primarily based on obtainable 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 will have to set context explicitly, which the following part covers.

{Hardware} necessities:

 

Function Minimal Advisable
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. Test your model with ollama --version and obtain the most recent from ollama.com/obtain if wanted.
  • Node.js 18 or later is required as a result of OpenClaw installs through npm. Ollama detects and prompts for this mechanically, however it’s value 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 help with none further configuration. For many customers beginning out, kimi-k2.5:cloud is the correct decide; 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 your complete 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 shouldn’t be already in your system, Ollama detects this and prompts you to put in it through npm. Affirm, 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 may cause actual injury. Learn it. Run OpenClaw in an remoted atmosphere in case you are not sure about what it could attain. The OpenClaw safety documentation covers this intimately.
  3. Mannequin selector: An inventory of really useful fashions seems. Choose one, or press Enter to make use of the mannequin you specified with --model. The selector exhibits each cloud and native fashions with context window notes.
  4. Onboarding: Ollama configures your supplier, installs the Gateway daemon, units the chosen mannequin as major, and, should 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.

In the event 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 operating while you do that, it restarts mechanically to select up the brand new settings. No guide restart wanted.

 

Configuring Context Size for Agent Workloads

 
That is the step most tutorials skip, and it’s the most typical purpose 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 process (internet search → learn web page → extract info → summarize → reply) accumulates context throughout each step. At 64k, you could have 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: Setting 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 the Ollama app
# Open Ollama settings → Context Size → transfer the slider to 64000 or larger

 

Confirm that the context was truly utilized and that your mannequin shouldn’t be 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 exhibits a cut up like 40% GPU / 60% CPU, the mannequin is being offloaded, and efficiency can be considerably degraded. CONTEXT ought to present 65536 or larger. If it exhibits 4096, your atmosphere variable didn’t take impact. Be sure to began ollama serve in the identical shell session the place you set the variable.

In the event you can not match the complete 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 operating, 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 telephone quantity linking and makes use of a correct bot token relatively 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 title), 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. In the event you lose it, you may 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, but it surely hyperlinks your precise WhatsApp account relatively than making a separate bot account. Concentrate on that earlier than continuing.

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

 

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

 
Right here is the complete mission this text has been constructing towards. A non-public Telegram bot that:

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

As soon as your Telegram channel is linked and the Gateway is operating, 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 Internet Search

In the event you launched with a cloud mannequin, Ollama installs the net search plugin mechanically. You’ll be able to confirm it’s energetic by asking your bot a query that requires present info: “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 should reply from coaching information or say it doesn’t know.

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

openclaw configure --section internet

 

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

 

// What a Multi-Step Activity 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 notice 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, usually in 20–40 seconds relying in your mannequin and connection pace.

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 guide synthesis may be delegated out of your telephone with a single message and return a synthesized reply when you do one thing else.

 

// The Python Script Method: Calling the Internet Search API Instantly

If you wish to construct on prime of this setup programmatically, for instance, scheduling each day analysis summaries or piping outcomes right into a database, you may 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)
#
# Easy methods to run:
#   python research_agent.py "What are the most recent developments in native LLMs?"

import sys
from ollama import chat, web_search, web_fetch

# ── Device registry ─────────────────────────────────────────────────────────────
# Map instrument names to precise callables so we are able to 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 info.

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

    Returns:
        The agent's ultimate 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 ultimate response, we break.

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

        # 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.operate.title
                tool_fn   = AVAILABLE_TOOLS.get(tool_name)

                if not tool_fn:
                    # Device not discovered -- inform the mannequin so it could regulate
                    print(f"[tool] {tool_name}: NOT FOUND")
                    messages.append({
                        "function":      "instrument",
                        "content material":   f"Device '{tool_name}' shouldn't be obtainable.",
                        "tool_name": tool_name,
                    })
                    proceed

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

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

                # Truncate instrument outcomes to remain inside context finances.
                # 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 ultimate 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 most recent developments in native LLMs?"
    run_research_agent(question)

 

Conditions:

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

 

Easy 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 occasions as of June 2026.
   Supply: arxiv.org/...

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

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

 

The instrument name truncation at 8,000 characters per result’s a very powerful sensible element on this script. With out it, a protracted internet web page fetched in a single instrument name can eat 20k–40k tokens of your context finances 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 probably 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 solely:

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 solution 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 through 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 through 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. Improve in case your GPU has VRAM headroom.
ENV OLLAMA_CONTEXT_LENGTH=64000

# ── Startup script ─────────────────────────────────────────────────────────────
# 1. Begin the Ollama server within the background
# 2. Anticipate it to be prepared
# 3. Launch OpenClaw headlessly with the desired 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
finished

# 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

# Preserve the container alive and observe 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

# Observe 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 simply wanted when operating 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 while 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 must:

 

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

Frequent points:

  • If messages will not be being processed, examine that the Gateway is definitely operating:
# Test 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:

 

  • In the event you see context size exceeded errors within the TUI log, your context window is simply too small for the duty. Improve 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 scale back context size, swap to a smaller mannequin, or transfer to a cloud mannequin. CPU offloading works however will make multi-step duties noticeably gradual.

 

Conclusion

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

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

For customers who care about the place their information goes, the native mannequin path is easy: a succesful mannequin, 25 GB of VRAM, and one context-length configuration ship a completely personal 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.

 

// Sources

 
 

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 may also discover Shittu on Twitter.


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments