OpenClaw Setup Guide
A multi-platform AI coding agent with terminal TUI, Web Dashboard, and Telegram Bot support.
Overview
OpenClaw is a feature-rich AI coding agent that supports terminal TUI interaction, Web Dashboard management, and Telegram Bot remote access. It is suitable for developers who want to run AI coding assistants on servers.
Supported Environment
This guide is suitable for Linux cloud servers, macOS, and Windows users.
403 Your request was blocked
When using Xiaomai API, Claude models must use an API key created in the Claude-Code-api group. Keys from other groups are blocked with 403. Also add the headers field in provider configuration:
"headers": {
"Authorization": "Bearer sk-xxxx"
}Authorizationmust matchapiKey, formatted asBearer sk-your-key- Choose the Claude-Code-api group when creating the key. See Create API Key
- Run
openclaw gateway restartafter modification
Links
| Resource | URL |
|---|---|
| OpenClaw website | https://openclaw.ai |
| Installation docs | https://docs.openclaw.ai/zh-CN/install/installer |
Features
- Terminal TUI: command-line interaction for SSH environments
- Web Dashboard: browser-based management panel
- Telegram Bot: remote chat through Telegram
- Multi-model support: Claude, GPT, Gemini, and more
- Gateway: built-in gateway service with reverse proxy support
- Skill extensions: install skills from the Dashboard
Installation and Initialization
Prerequisites
- Node.js: Node 24 is required, or Node 22 LTS 22.16+. If the server has no Node.js, use
install-cli.shself-contained installation below - Git: required during installation
- curl / bash: required on Linux/macOS
Step 1: Run the Installer
Choose the installation method for your system.
macOS / Linux / WSL standard installation:
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bashmacOS / Linux / WSL self-contained installation without system Node.js:
curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install-cli.sh | bashAbout install-cli.sh
install-cli.sh downloads a local Node.js runtime automatically and does not depend on system Node.js. It is suitable for servers without Node.js.
Windows PowerShell 5+:
iwr -useb https://openclaw.ai/install.ps1 | iexWait for installation to finish.
Step 2: Initialize Configuration
During installation, choose:
| Step | Choice | Description |
|---|---|---|
| Startup mode | QuickStart | Fast setup mode |
| Provider setup | Skip for now | Skip and edit config manually later |
| Adapter | anthropic | Choose the Anthropic adapter |
| Model | opus-4.5 | Or choose the model you need |
| Social adapter | As needed | Telegram is optional |
| Skill installation | Skip | Install later from Dashboard |
| Hook selection | Select all | Press Space to select all, then Enter |
| Open method | Skip | Skip for now |
| Shell completion | yes | Install shell completion |
Channel and Model Configuration
Step 1: Edit Configuration File
Open the OpenClaw configuration file:
vim ~/.openclaw/openclaw.jsonUse the full configuration example below and fill in provider and model information.
Step 2: Enter API Key
In models.providers, replace apiKey and headers.Authorization with the API key created in the Xiaomai API console.
Step 3: Restart Gateway
openclaw gateway restartStep 4: Verify
Run this command to enter TUI and test the model:
openclaw tuiAfter a successful test, type /quit to exit TUI.
Access Dashboard in Browser
Get Dashboard URL
Run the command in the console to get the Dashboard URL, then open it in a browser.
Remote Server Note
If OpenClaw runs on a remote server:
1. Configure reverse proxy
Use Nginx or another reverse proxy and set up an SSL certificate.
2. Modify configuration
Edit ~/.openclaw/openclaw.json and add this under gateway:
"controlUi": {
"allowInsecureAuth": true
}3. Restart gateway
openclaw gateway restartOpen the tokenized Dashboard URL to enter the admin panel.
Configure Telegram Bot (Optional)
If you selected the Telegram adapter during installation:
Step 1: Chat with the Bot
Open Telegram and start a conversation with the bot you created through @BotFather.
Step 2: Get Pairing Code
After the first message, you receive a Pairing Code.
Step 3: Approve Pairing
Run this command:
openclaw pairing approve telegram your_pairing_codeAfter pairing succeeds, you can chat with OpenClaw through Telegram Bot.
Full Configuration Example
This is a Windows example for connecting OpenClaw to Xiaomai API, with path ~/.openclaw/openclaw.json:
Note
sk-xxxx and xxxxx are placeholders. Replace them with your own API key and Bot Token.
{
"messages": {
"ackReactionScope": "group-mentions"
},
"agents": {
"defaults": {
"model": {
"primary": "xiaomai-claude/claude-sonnet-5-5"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
},
"compaction": {
"mode": "safeguard"
},
"workspace": "C:\\Users\\Administrator\\.openclaw\\workspace"
}
},
"models": {
"providers": {
"xiaomai-claude": {
"baseUrl": "https://xiaomai.win/v1",
"apiKey": "sk-xxxx",
"api": "openai-completions",
"headers": {
"Authorization": "Bearer sk-xxxx"
},
"models": [
{
"id": "claude-sonnet-5-5",
"name": "claude-sonnet-5-5",
"contextWindow": 200000,
"maxTokens": 32000,
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
}
}
]
},
"xiaomai-codex": {
"baseUrl": "https://xiaomai.win/v1",
"apiKey": "sk-xxxx",
"api": "openai-completions",
"headers": {
"Authorization": "Bearer sk-xxxx"
},
"models": [
{
"id": "gpt-6.2-sol",
"name": "gpt-6.2-sol",
"contextWindow": 200000,
"maxTokens": 32000,
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
}
}
]
}
}
},
"gateway": {
"mode": "local",
"auth": {
"mode": "token",
"token": "xxxx"
},
"port": 18789,
"bind": "loopback",
"tailscale": {
"mode": "off",
"resetOnExit": false
}
},
"plugins": {
"entries": {
"telegram": {
"enabled": true
}
}
},
"channels": {
"telegram": {
"enabled": true,
"botToken": "xxxxx"
}
},
"logging": {
"level": "trace",
"consoleLevel": "debug",
"consoleStyle": "pretty"
},
"commands": {
"restart": true
},
"skills": {
"install": {
"nodeManager": "npm"
}
}
}Key Fields
| Field | Description |
|---|---|
agents.defaults.model.primary | Default model, formatted as provider/model-id |
agents.defaults.maxConcurrent | Max main-agent concurrency |
agents.defaults.subagents.maxConcurrent | Max sub-agent concurrency |
agents.defaults.compaction.mode | Context compaction mode. safeguard is the safer mode |
agents.defaults.workspace | Workspace path. Adjust for your system |
models.providers | Model provider configuration. Multiple providers can be configured |
models.providers.*.baseUrl | API base URL. Xiaomai API uses https://xiaomai.win/v1 |
models.providers.*.apiKey | API key for the corresponding group. Claude models use the Claude-Code-api group |
models.providers.*.api | API protocol. Use openai-completions |
models.providers.*.headers | Request headers. Must include Authorization |
gateway.port | Gateway port. Default is 18789 |
gateway.bind | Binding mode. loopback allows local access only |
channels.telegram.botToken | Telegram Bot Token from @BotFather |
logging.level | Log level. Use trace when troubleshooting |
Notes
headers.Authorizationmust matchapiKey, formatted asBearer sk-xxxx- Group: the key for the
xiaomai-claudeprovider must come from the Claude-Code-api group - For
workspace, Windows uses escaped backslashes and Linux/macOS uses/, such as/root/.openclaw/workspace costcan be set to 0 when using Xiaomai API as a gateway
FAQ
Installer failed
- Confirm network access to
openclaw.ai - Confirm
curlandbashare installed - If the server is in mainland China, a proxy may be needed
- If no Node.js environment exists, use
install-cli.shinstead ofinstall.sh
openclaw command not found
- Check whether PATH includes the npm global directory
- On Linux/macOS, run
npm config get prefixand make sure it is in$PATH - On Windows, run
npm config get prefixand add the output path to user PATH - Reopen the terminal or run
source ~/.bashrcorsource ~/.zshrc
npm EACCES permission error on Linux
- npm global directory may point to a root-owned path
- The installer tries to switch prefix to
~/.npm-globaland update shell config - If it still fails, run:
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc403 Your request was blocked
If the request returns 403 Your request was blocked, the key is usually from the wrong group or request headers are missing. Make sure the key comes from the Claude-Code-api group, and add headers in provider configuration:
"headers": {
"Authorization": "Bearer sk-xxxx"
}Important
Authorizationmust matchapiKey, formatted asBearer sk-your-key- Claude models must use a key from the Claude-Code-api group, otherwise requests are blocked
- Run
openclaw gateway restartafter configuration
Model still unavailable after gateway restart
- Check whether the API key is correct
- Confirm the key group supports the selected model
- Check OpenClaw logs for details