# ChatGPT-on-WeChat 接入指南

ChatGPT-on-WeChat（简称 cow）是一款开源的聊天机器人框架，可把 AI 接入微信、企业微信、飞书、钉钉等渠道。本文介绍如何让它通过 UModelverse 平台调用模型。

## **系统要求**

| 平台 | 要求 |
| --- | --- |
| Windows | Windows 10 或 Windows 11 |
| macOS | macOS 10.15 (Catalina) 或更高版本 |
| Linux | 主流发行版（Ubuntu、Debian 等） |

所有平台均需要：Python 3.8+ 与网络连接（也可使用 Docker 部署）。

## **1. 安装**

按 [ChatGPT-on-WeChat 官方文档](https://github.com/zhayujie/chatgpt-on-wechat) 克隆项目并安装依赖：

```
git clone https://github.com/zhayujie/chatgpt-on-wechat
cd chatgpt-on-wechat
pip install -r requirements.txt
```

## **2. 获取 API Key**

访问 [UModelverse 控制台](https://console.ucloud.cn/modelverse/api) 获取您的 API 密钥。可用模型见 UModelverse 平台[支持的模型](https://api.modelverse.cn/v1/models)。

## **3. 配置 UModelverse 模型**

UModelverse 走 OpenAI 兼容协议。在项目根目录的 `config.json` 中填写以下字段（将 `YOUR_API_KEY` 替换为实际 Key）：

```
{
  "model": "qwen3.7-max",
  "open_ai_api_key": "",
  "open_ai_api_base": "",
  "channel_type": "wx",
  "single_chat_prefix": ["bot", "@bot"],
  "group_chat_prefix": ["@bot"],
  "group_name_white_list": ["ALL_GROUP"],
  "custom_api_key": "YOUR_API_KEY",
  "custom_api_base": "https://api.modelverse.cn/v1",
  "bot_type": "custom",
  "use_linkai": false
}
```

> 说明：
>
> - `bot_type` 设为 `custom`，并使用 `custom_api_key` / `custom_api_base` 指定 UModelverse 的 API 信息；`open_ai_api_key` 和 `open_ai_api_base` 留空即可。
> - `model` 填 UModelverse 平台[支持的模型](https://api.modelverse.cn/v1/models)之一，例如 `qwen3.7-max`。
> - `custom_api_base` 须带 `/v1` 后缀。
> - `channel_type` 按接入渠道设置（如微信 `wx`、企业微信、飞书、钉钉等），其余渠道凭证参数请参考官方文档。

## **4. 启动**

```
python app.py
```

启动后按终端提示扫码登录，即可在对应渠道中与机器人对话。

## **常见问题**

### 回复报错认证失败或无法连接？

请逐项确认：

1.  `custom_api_key` 来自 UModelverse 平台，复制完整且无空格。
    
2.  `custom_api_base` 为 `https://api.modelverse.cn/v1`（带 `/v1`），`bot_type` 为 `custom`。
    
3.  `model` 是 UModelverse 平台[支持的模型](https://api.modelverse.cn/v1/models)之一，没有写错。
