← All articles

Coding

OpenClaw Guide 2026: Install, Configure, and Run Your Self-Hosted AI Agent

6 min read

Updated

Learn how to install, configure, and secure OpenClaw, a free, self-hosted AI agent that integrates with WhatsApp, Telegram, Discord, and Slack.

OpenClaw is a free, open-source, self-hosted AI agent designed to run locally or on a virtual private server (VPS). It connects directly to popular messaging apps, allowing you to trigger tasks, run scripts, and manage workflows using natural language commands.

This guide walk you through installing OpenClaw, connecting it to messaging channels, configuring language models, and applying essential safety configurations.


What is OpenClaw?

OpenClaw is an MIT-licensed, model-agnostic AI agent that runs as a background service. It stores memory locally as Markdown files and executes skills such as browser automation, shell commands, calendar scheduling, and email dispatch. You can power it using API keys from providers like Anthropic and OpenAI, or connect it to locally run models via Ollama.


Prerequisites and Safety Warnings

Before starting the installation, ensure your environment meets the minimum requirements and familiarize yourself with the security precautions.

System Requirements

  • Runtime: Node.js 22 or newer.
  • OS: macOS, Linux, or Windows with WSL2.
  • LLM Access: An API key from Anthropic or OpenAI, or a local instance of Ollama running.
  • Sandbox (Recommended): Docker installed for sandboxed execution of shell and browser commands.
  • Hosting (Optional): A dedicated server or a low-cost VPS ($6–$13/month) to keep the agent running 24/7.

Essential Security Practices

Because OpenClaw can execute shell commands, edit files, and browse the web, a misconfigured instance can present a significant security vulnerability.

  • Restrict the Gateway Port: By default, OpenClaw listens on port 18789. Never expose this port to the public internet. Ensure it binds only to your local loopback address (127.0.0.1).
  • Audit Third-Party Skills: Before installing any skill from community directories, inspect the source code to ensure it does not execute unauthorized commands.
  • Limit API Key Scope: Use a dedicated API key with hard billing limits rather than your primary organization key.
  • Use Sandboxing: Keep OpenClaw’s execution environment isolated in a Docker container to prevent accidental modifications to your host file system.

Step 1: Install OpenClaw

One-Command Installation

Run the following script in your terminal to install the OpenClaw binary:

curl -fsSL https://openclaw.ai/install.sh | bash

Alternatively, you can install it globally via npm:

npm install -g openclaw@latest

Run the Onboarding Wizard

Launch the setup assistant to configure your credentials and run the background service:

openclaw onboard --install-daemon

The wizard guides you through:

  1. Model Authentication: Inputting your Anthropic/OpenAI API keys or targeting a local Ollama endpoint.
  2. Gateway Configuration: Setting up the network binding (localhost recommended).
  3. Channel Connection: Setting up your initial messaging integrations.
  4. Daemon Registration: Staggering OpenClaw as a background service.

Verify the Installation

Check that the daemon and its core dependencies are working correctly:

openclaw status
openclaw health
openclaw doctor

A successful status report looks similar to this:

status:  running (pid 41832)
health:  ok (model=claude-sonnet, channels=1, skills=0)
doctor:  all checks passed

Step 2: Configure Models

OpenClaw allows you to designate different models for default operations versus intensive reasoning tasks.

Anthropic (Claude)

openclaw config set model.provider anthropic
openclaw config set model.default claude-haiku-4
openclaw config set model.reasoning claude-sonnet-4

OpenAI (GPT)

openclaw config set model.provider openai
openclaw config set model.default gpt-4o-mini
openclaw config set model.reasoning gpt-4o

Local Ollama

ollama pull qwen2.5:14b
openclaw config set model.provider ollama
openclaw config set model.default qwen2.5:14b
openclaw config set model.endpoint http://localhost:11434

Verify your active routing configuration using:

openclaw config show model

Step 3: Connect a Messaging Channel

You can connect one or more communication channels to interact with your agent.

WhatsApp

openclaw channel add whatsapp

Scan the terminal-generated QR code using WhatsApp on your mobile device (Settings > Linked Devices > Link a Device).

Telegram

  1. Contact @BotFather on Telegram, send the /newbot command, and save the returned bot token.
  2. Register the bot with OpenClaw:
    openclaw channel add telegram --token <BOT_TOKEN>
    
  3. Message your bot to begin interacting.

Slack

  1. Create a Slack App in your workspace via the Slack API portal. Enable Socket Mode and add the chat:write and im:history scopes.
  2. Link the app tokens to OpenClaw:
    openclaw channel add slack --app-token xapp-... --bot-token xoxb-...
    

To review your active messaging endpoints:

openclaw channel list

Cost Analysis

While the OpenClaw software is entirely free, operational costs depend on your chosen hosting infrastructure and LLM usage.

SetupEstimated Monthly CostOperational Context
Local Ollama$0Dependent on the performance of your local hardware
Light Cloud API$15 - $40Fulfilling approximately 5–10 typical tasks per day
Hybrid Routing$40 - $80Combining cheap default models with premium reasoning models
Heavy Cloud API$100 - $200+Intensive, always-on multi-agent execution
VPS Hosting$6 - $13Required for 24/7 standalone availability

Tips to Lower Token Expenses:

  1. Dynamic Routing: Direct simple checks to smaller models and scale up to reasoning models only when requested by a skill.
  2. Prompt Caching: Enable native prompt caching in your provider settings to save on repeated context payloads.
  3. Scheduled Off-Peak Tasks: Use the openclaw cron module to queue non-urgent batch requests.

Troubleshooting Common Issues

Gateway Disconnects (1006 / 1008 Errors)

If your messaging channels stop responding, the gateway may have dropped connection.

openclaw doctor
openclaw restart gateway

Note: Ensure you are running version v2026.3.23 or higher, which includes stability updates for channel sockets.

Loss of Long-Term Memory

If the agent begins dropping details from a long conversation:

  • Ensure your software is updated to benefit from memory compaction optimization.
  • Directly modify the markdown files stored under ~/.openclaw/memory/ to fix errors or add persistent facts.
  • Pin critical context files to prevent them from rotating out during compaction:
    openclaw memory pin <filename>
    

WhatsApp QR Code Fails to Sync

If you encounter a loop where the terminal requests a fresh scan shortly after linking:

openclaw channel remove whatsapp
rm -rf ~/.openclaw/channels/whatsapp
openclaw channel add whatsapp

Rate Limiting on Automated Schedules

If multiple cron jobs run simultaneously and fail due to API rate limit limits, add a jitter config to stagger tasks:

openclaw config set cron.jitter 30s
openclaw config set skills.retry.strategy exponential

Security Hardening Checklist

Before leaving OpenClaw unattended, complete these checks:

  1. Confirm the gateway is restricted to localhost by verifying the bind address:
    openclaw config set gateway.bind 127.0.0.1
    openclaw restart gateway
    
  2. Set up an SSH tunnel or use Tailscale to access the web panel remotely rather than exposing the port:
    ssh -L 18789:localhost:18789 user@your-server-ip
    
  3. Verify that skill execution runs in a sandboxed Docker container.
  4. Manually review third-party skills before installing them.
  5. Create a dedicated API key in your OpenAI or Anthropic console and assign a monthly spend threshold.
  6. Enable automatic patch updates to ensure you receive security fixes:
    openclaw config set updates.auto true