> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omnimux.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenClaw + Telegram

> 将 OpenClaw 连接到 OmniMux

## 概述

<Note>
  OmniMux 网关统一使用 Base URL：`https://api.omnimux.ai`（OpenAI 兼容客户端通常填 `https://api.omnimux.ai/v1`）。控制台为 [omnimux.ai/dashboard](https://omnimux.ai/dashboard)。文中的模型 ID 仅为示例，请以控制台或 `GET /v1/models` 为准。
</Note>

OpenClaw 是一个开源的 AI 智能体 Gateway 网关，充当聊天应用与 AI 智能体之间的桥梁。它通过一个中心化的 Gateway 进程，将 Telegram、WhatsApp、Discord 等聊天平台连接到 AI 编程智能体，实现在聊天窗口中直接与 AI 进行编程交互。

通过将 **OmniMux API** 配置为 OpenClaw 的自定义模型提供商，并接入 **Telegram Bot**，你可以在 Telegram 中直接使用 OmniMux 提供的 Claude 模型（如 **Claude 4.6 Opus**、**Claude 4.5 Sonnet**、**Claude 4.5 Haiku**）进行 AI 辅助编程对话。

**本文将介绍：**

* 安装并配置 OpenClaw Gateway
* 创建 Telegram Bot 并接入 OpenClaw
* 将 OmniMux API 配置为自定义模型提供商
* 验证连接并开始使用

## 系统环境检查

在开始安装之前，建议先运行环境检查工具，确保你的系统满足 OpenClaw 的运行要求。

### 下载检查工具

从 [GitHub Releases](https://github.com/suuuuuu-1/openclaw-env-checker/releases) 下载对应平台的检查工具：

| 平台                    | 文件名                            |
| --------------------- | ------------------------------ |
| Windows               | `openclaw-checker-win-x64.exe` |
| macOS (Intel)         | `openclaw-checker-macos-x64`   |
| macOS (Apple Silicon) | `openclaw-checker-macos-arm64` |
| Linux                 | `openclaw-checker-linux-x64`   |

### 检查项目

工具会自动检查以下条件：

* ✅ Node.js 版本（需要 >= 22.12.0）
* ✅ npm 可用
* ✅ Git 可用
* ✅ 网络连通性（github.com、npmjs.org、omnimux.ai）

如果检查未通过，工具会给出具体的修复建议。

## 使用前准备

在开始配置之前，请确保已完成以下准备工作：

### 1. 安装 Node.js

OpenClaw 通过 npm 安装，需要先安装 Node.js 22 或更高版本。

访问 [Node.js 官网](https://nodejs.org/zh-cn/download),下载 Windows 安装包(.msi 文件),双击运行安装程序。

安装完成后,打开 PowerShell 验证:

```bash theme={null}
node --version
npm --version
```

建议以管理员身份运行 PowerShell,避免后续安装时出现权限问题。

**方式 1: 使用安装包**

访问 [Node.js 官网](https://nodejs.org/zh-cn/download),下载 macOS 安装包(.pkg 文件),双击运行安装程序。

**方式 2: 使用 Homebrew**

```bash theme={null}
brew install node
```

安装完成后,打开终端验证:

```bash theme={null}
node --version
npm --version
```

如果后续安装时遇到权限问题,可能需要在命令前加 `sudo`。

### 2. 获取 OmniMux API Key

* 登录 [OmniMux 控制台](https://omnimux.ai/dashboard)
* 在控制台中找到 API Keys，点击"创建新Key"按钮，然后复制生成的 Key
* API Key 通常以 `sk-` 开头，请妥善保存

### 3. 准备一个 Telegram 账号

用于后续创建 Bot 和测试接入。

## 第一步：安装 OpenClaw

在终端中执行：

```bash theme={null}
npm install -g openclaw@latest
```

## 第二步：初始化引导

运行新手引导命令，OpenClaw 会引导你完成初始配置并安装后台守护服务：

```bash theme={null}
openclaw onboard --install-daemon
```

### 1. 确认安装

系统会提示安装风险说明，确认同意后继续：

### 2. 选择安装模式

系统会提示选择安装模式，选择 **Quickstart** 即可：

### 3. 选择供应商

系统会提示选择模型供应商，这里选择 **跳过（Skip）**，后续我们会手动配置 OmniMux 作为自定义供应商：

### 4. 选择模型

系统会提示选择要启用的模型，选择 **All（全部）** 即可：

### 5. 选择默认模型

系统会提示选择默认模型，选择 **Keep current（保持当前）** 即可：

## 第三步：创建 Telegram Bot

引导流程会提示选择要接入的聊天渠道，选择 **Telegram (Bot API)**。

### 1. 访问 BotFather

在 Telegram 中访问 [@BotFather](https://t.me/BotFather)，点击 **START BOT** 开始对话：

### 2. 创建 Bot

在对话框中输入 `/start`，BotFather 会返回可用命令列表：

输入 `/newbot`，按提示设置一个唯一的 **Bot 用户名**，名称必须以 `bot` 结尾（如 `my_omnimux_bot`）。

创建成功后，BotFather 会返回一条包含 **Token** 的消息，格式类似：

```
123456789:ABCdefGHIjklMNOpqrsTUVwxyz
```

复制并保存这个 Token。

### 3. 填入 Token

回到终端的引导流程，将复制的 Bot Token 粘贴到提示框中并确认：

### 4. 重启网关

Token 填入完成后，重启 Gateway 网关使配置生效：

## 第四步：配置 OmniMux API

### 1. 找到配置文件

找到 OpenClaw 安装目录下的配置文件 `openclaw.json` 并打开编辑：

### 2. 配置模型提供商

在 `openclaw.json` 中找到 `models` 字段，添加 OmniMux 作为自定义模型提供商：

```json theme={null}
"models": {
"providers": {
"omnimux-anthropic": {
"api": "anthropic-messages",
"baseUrl": "https://api.omnimux.ai",
"apiKey": "你的 OmniMux API Key",
"models": [
{ "id": "claude-fable-5", "name": "Claude Fable 5" },
{ "id": "claude-opus-5", "name": "Claude Opus 5" },
{ "id": "claude-opus-4-8", "name": "Claude Opus 4.8" },
{ "id": "claude-opus-4-7", "name": "Claude Opus 4.7" },
{ "id": "claude-opus-4-6", "name": "Claude Opus 4.6" },
{ "id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6" },
{ "id": "claude-sonnet-5", "name": "Claude Sonnet 5" },
{ "id": "claude-opus-4-5-20251101", "name": "Claude Opus 4.5" },
{ "id": "claude-sonnet-4-5-20250929", "name": "Claude Sonnet 4.5" },
{ "id": "claude-haiku-4-5-20251001", "name": "Claude Haiku 4.5" }
]
},
"omnimux-google": {
"api": "google-generative-ai",
"baseUrl": "https://api.omnimux.ai/v1beta",
"apiKey": "你的 OmniMux API Key",
"models": [
{ "id": "gemini-3.1-flash-lite-preview", "name": "Gemini 3.1 Flash Lite" },
{ "id": "gemini-3.1-pro-preview", "name": "Gemini 3.1 Pro" },
{ "id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro" },
{ "id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash" },
{ "id": "gemini-3-pro-preview", "name": "Gemini 3.0 Pro" },
{ "id": "gemini-3-flash-preview", "name": "Gemini 3.0 Flash" }
]
},
"omnimux-openai": {
"api": "openai-completions",
"baseUrl": "https://api.omnimux.ai/v1",
"apiKey": "你的 OmniMux API Key",
"models": [
{ "id": "gpt-5.4", "name": "GPT-5.4" },
{ "id": "gpt-5.2", "name": "GPT-5.2" },
{ "id": "gpt-5.1", "name": "GPT-5.1" },
{ "id": "gpt-5.1-chat", "name": "GPT-5.1 Chat" },
{ "id": "gpt-5.1-thinking", "name": "GPT-5.1 Thinking" },
{ "id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro (OpenAI SDK)" },
{ "id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash (OpenAI SDK)" },
{ "id": "gemini-3-pro-preview", "name": "Gemini 3.0 Pro (OpenAI SDK)" },
{ "id": "gemini-3-flash-preview", "name": "Gemini 3.0 Flash (OpenAI SDK)" },
{ "id": "doubao-seed-2.0-pro", "name": "Doubao Seed 2.0 Pro" },
{ "id": "doubao-seed-2.0-lite", "name": "Doubao Seed 2.0 Lite" },
{ "id": "doubao-seed-2.0-mini", "name": "Doubao Seed 2.0 Mini" },
{ "id": "doubao-seed-2.0-code", "name": "Doubao Seed 2.0 Code" },
{ "id": "kimi-k2-thinking", "name": "Kimi K2 Thinking" },
{ "id": "kimi-k2-thinking-turbo", "name": "Kimi K2 Thinking Turbo" }
]
}
}
}
```

将 `"你的 OmniMux API Key"` 替换为你在 [OmniMux 控制台](https://omnimux.ai/dashboard) 获取的实际 API Key。

### 3. 配置默认模型

在 `agents` 字段中配置默认使用的模型，将 `model.primary` 指向刚才添加的 OmniMux 模型：

```json theme={null}
"model": {
"primary": "omnimux-anthropic/claude-opus-5"
}
```

### 4. 确认 Telegram 配置

确认 `channels` 字段中的 Telegram 配置。`botToken` 已在引导流程中自动填入，无需修改：

```json theme={null}
"channels": {
"telegram": {
"enabled": true,
"botToken": "你的Bot Token（已自动填入）",
"dmPolicy": "pairing",
"groups": { "*": { "requireMention": true } }
}
}
```

* `enabled`：启用 Telegram 渠道
* `dmPolicy`：设为 `"pairing"`，未授权用户私聊时需通过配对码验证
* `groups`：`"*"` 表示允许所有群组，`requireMention` 为 `true` 表示在群组中需要 @Bot 才会响应

## 第五步：验证连接

### 1. 访问你的 Bot

在 Telegram 中搜索你刚才创建的 Bot 用户名，打开对话：

### 2. 获取配对码

向 Bot 发送 `/start`，Bot 会返回一个配对码（Pairing Code）：

### 3. 完成配对

新开一个终端窗口，运行以下命令完成配对：

```bash theme={null}
openclaw pairing approve telegram <配对码>
```

将 `<配对码>` 替换为 Bot 返回的实际配对码，注意去掉两边的尖括号 `<>`。

### 4. 测试对话

回到原来的终端窗口，输入以下内容测试连接是否成功：

```
Wake up, my friend!
```

配对成功后，你在 Telegram 中向 Bot 发送消息也会收到 AI 回复，说明接入已完成。
