← Back to all free guides

Set Up OpenClaw
In One Afternoon

One bot in Telegram, every model behind it. The exact install, the Telegram connection, and how to swap models with one command.

The whole point of running your own gateway is that you are never stuck with one company's model. You text one bot, and behind it you can swap between Claude, GPT, Gemini, cheaper models, or something running locally on your own machine.

OpenClaw is an MIT-licensed, self-hosted gateway that connects chat apps like Telegram, WhatsApp, Discord, Slack and iMessage to AI agents. It is genuinely more work upfront than a polished commercial app. Set aside an afternoon. What you get back is a setup that outlives whichever model is winning this month.

Before You Start

If you only want to switch models, start here

One OpenRouter key gets you most major models behind a single credential, so you can swap without going and creating an account with every provider. Add the direct keys later for the two you use daily.

Install And Onboard

This is the whole install. The onboard command sets up your first provider and installs the background service in one go.

Install (terminal)
# 1. Check your Node version first (needs 22+, 26 recommended) node --version # If you need it, on Mac: brew install node # 2. Install OpenClaw globally npm install -g openclaw@latest --allow-scripts=openclaw # (drop the --allow-scripts flag on npm 11.12 and earlier) openclaw --version # 3. Onboard with whichever provider you want first, # and install it as a background service in the same step. # Anthropic / Claude: openclaw onboard --install-daemon --anthropic-api-key "sk-ant-YOUR-KEY" # or OpenAI: openclaw onboard --install-daemon --openai-api-key "sk-YOUR-KEY" # or OpenRouter (one key, most models, easiest if you want to # switch constantly without collecting five separate keys): openclaw onboard --install-daemon --auth-choice apiKey \ --token-provider openrouter --token "sk-or-YOUR-KEY" # 4. Open the local dashboard to confirm it is alive openclaw dashboard # then visit http://127.0.0.1:18789/ # If the openclaw command is not found, your npm bin isn't on PATH: export PATH="$(npm config get prefix)/bin:$PATH" # add that line to your ~/.zshrc so it sticks
Connect Telegram

This is the part that makes it feel like magic, because now it is just a chat you text from your phone.

  1. In Telegram, search @BotFather and send /newbot. Name it, then copy the token it gives you.
  2. Open ~/.openclaw/openclaw.json and paste the token into channels.telegram.botToken.
  3. Leave dmPolicy set to pairing so a stranger who finds your bot cannot just start using your API keys.
  4. Restart the daemon, message your bot once, then approve the pairing code from the terminal.
~/.openclaw/openclaw.json
// ~/.openclaw/openclaw.json // Add a key per provider you want to be able to switch to. { "env": { "ANTHROPIC_API_KEY": "sk-ant-YOUR-KEY", "OPENAI_API_KEY": "sk-YOUR-KEY" }, "agents": { "defaults": { "model": { "primary": "anthropic/claude-sonnet-4-6" }, "compaction": { "mode": "safeguard" } } }, "channels": { "telegram": { "enabled": true, "botToken": "PASTE-THE-BOTFATHER-TOKEN-HERE", "dmPolicy": "pairing" } }, "gateway": { "mode": "local", "bind": "loopback", "auth": { "mode": "token" } } }

The error you will probably hit

A deleteWebhook 401 on startup means the bot token is wrong. Usually a trailing space from the copy-paste. Go back to BotFather, revoke and reissue the token, paste it clean, restart.

Switching Models, The Actual Point

Once keys for more than one provider are in the config, switching is a single command, or one message from your phone. Here is the command set worth keeping.

Everyday commands
# After editing the config, restart so it picks up Telegram openclaw daemon restart # Message your bot once in Telegram, then approve the pairing request openclaw pairing list telegram openclaw pairing approve telegram <CODE> # Confirm your models actually loaded openclaw models list # Check every channel connection openclaw channels status --probe # Change the default model from the terminal openclaw model set <provider/model-name> # Or switch on the fly from inside Telegram /model # When something is wrong, this is the first place to look openclaw daemon logs

How I actually split it: a frontier model for anything where being wrong is expensive, a cheap fast one for reminders and quick lookups, and whichever model is currently best at the specific job for that job. You can also point it at a local model through Ollama or LM Studio when you want something to never leave your machine.

Be honest about the tradeoff

You are the one running this. That means you handle updates, uptime, and keeping your own API keys safe, and you pay per token instead of a flat subscription. In exchange nothing you build is trapped in someone else's product, and the day a better model ships you change one line.