← Back to all free guides

Set Up OpenClaw
In One Afternoon

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

The whole reason to run your own gateway is that you’re never stuck with one company’s model. You text one bot, and behind it you can swap between Claude, GPT, Gemini, cheaper models, or a model running on your own machine.

OpenClaw is a free, MIT-licensed assistant you host yourself. It connects chat apps like Telegram, WhatsApp, Discord, Slack and iMessage to AI models. It takes more setup than a polished app, so set aside an afternoon. What you get back is a setup that outlives whichever model is winning this month.

Before You Start

Only Want To Switch Models? Start Here

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

Install And Onboard

Run these in Terminal. The onboard step walks you through picking a provider, asks for your key, and installs the background service so it keeps running after you close the window. Full details are in the install docs.

Install (terminal)
# 1. Check Node (needs 24.16+ or 26.1+; 26 is recommended) node --version # On a Mac, if you need it: brew install node # 2. Install OpenClaw # Easiest: the official installer (it adds Node for you if it's missing) curl -fsSL https://openclaw.ai/install.sh | bash # Or with npm: npm install -g openclaw@latest --allow-scripts=openclaw # (on npm 11.15 and earlier, drop the --allow-scripts flag) openclaw --version # 3. Run setup and install the background service in one go. # Pick your provider when it asks and paste your API key. openclaw onboard --install-daemon # 4. Confirm it's alive openclaw gateway status # should show it listening on port 18789 openclaw doctor # flags config problems openclaw dashboard # opens the control panel in your browser # If "openclaw: command not found", your npm bin isn't on PATH: export PATH="$(npm config get prefix)/bin:$PATH" # add that line to ~/.zshrc so it sticks
Connect Telegram

Telegram turns your setup into a chat you text from your phone, and that’s when it starts to feel like magic.

  1. In Telegram, search @BotFather and send /newbot. Name it, then copy the token it gives you.
  2. Open ~/.openclaw/openclaw.json and add the Telegram section below with your token.
  3. Leave dmPolicy on pairing (the default), so a stranger who finds your bot can’t start spending your API credits.
  4. Message your bot once, then approve the pairing code from the terminal with the commands in the next section.
~/.openclaw/openclaw.json
// ~/.openclaw/openclaw.json (JSON5, so comments are fine) // Keep what onboarding already wrote and add or merge these sections. { env: { vars: { // one key per provider you want to switch to ANTHROPIC_API_KEY: "sk-ant-YOUR-KEY", OPENAI_API_KEY: "sk-YOUR-KEY", }, }, agents: { defaults: { model: { primary: "anthropic/claude-sonnet-5-5", // tried in order if the primary fails; copy exact refs from: openclaw models list fallbacks: ["anthropic/claude-haiku-5-5"], }, }, }, channels: { telegram: { enabled: true, botToken: "PASTE-THE-BOTFATHER-TOKEN-HERE", dmPolicy: "pairing", }, }, }

The Error You’ll Probably Hit

If startup says your token is unauthorized, the token is wrong, usually from a stray space when you pasted it. Ask BotFather for a fresh token, paste it clean and restart. (Telegram docs)

Switching Models, The Actual Point

Once more than one provider’s key is in the config, switching is one command in the terminal or one message from your phone. Here’s the command set worth keeping.

Everyday commands
# Apply changes (the gateway hot-reloads most edits; restart if the bot stays quiet) openclaw gateway restart # Message your bot once in Telegram, then approve the pairing request (codes expire after 1 hour) openclaw pairing list telegram openclaw pairing approve telegram <CODE> # See which models you can use, and set the default openclaw models list openclaw models set <provider/model> # Check your chat connections openclaw channels status # Switch from inside Telegram (this chat only) /model anthropic/claude-haiku-5-5 /models # browse what's available # When something breaks openclaw logs openclaw doctor --fix

How I actually split it. Anything where being wrong is expensive goes to a frontier model. Reminders and quick lookups go to a cheap, fast one, like Claude Haiku 5.5, which costs a fraction of Sonnet 5.5 (pricing). Everything else goes to whichever model is best at that job right now. For anything that should never leave your computer, point it at a local model through Ollama or LM Studio.

When Something Breaks

Run openclaw doctor first. If that doesn’t make the problem obvious, paste this into Claude or ChatGPT with your output. Take out your keys and tokens before you paste anything.

OpenClaw Fix-It
You are helping me fix my OpenClaw setup. I'm not a developer, so explain every step in plain English and give me commands I can copy exactly. MY SETUP: - Computer: [Mac / Linux / Windows with WSL2] - What I'm trying to do: [e.g. get my Telegram bot to answer] - What happens instead: [e.g. no reply, error message] HERE IS WHAT MY TERMINAL SAYS (I removed my API keys and bot token): [paste the output of: openclaw doctor] [paste the last 50 lines of: openclaw logs] [paste my ~/.openclaw/openclaw.json with every key and token replaced by XXXX] WHAT TO DO: 1. Tell me the most likely cause in one sentence. 2. Give me the fix as numbered steps, one command per step, and tell me what I should see after each one. 3. If you need more information, ask me for exactly one thing at a time. RULES: - Before you answer, check the current OpenClaw docs at docs.openclaw.ai, because commands change often. Don't invent commands or config keys. - Never ask me to paste a real API key or bot token. - Don't suggest turning off pairing or exposing the gateway to the internet to make something work.

Be Honest About The Tradeoff

You’re the one running this. You handle updates, uptime and keeping your API keys safe, and you pay per use 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.