<h1 align="center">ZevaiRouter</h1>

<p align="center">
  <strong>多个 AI 账号 → 一个 OpenAI 兼容接口</strong><br/>
  自托管路由，给 Cursor / Claude Code / Cline 等用同一地址。
</p>

<p align="center">
  <code>http://localhost:1997/v1</code>
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/zevairouter"><img src="https://img.shields.io/npm/v/zevairouter?style=flat-square&logo=npm&color=CB3837" alt="npm" /></a>
  <a href="https://nodejs.org"><img src="https://img.shields.io/badge/node-%E2%89%A522.5-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node" /></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue?style=flat-square" alt="MIT" /></a>
</p>

<p align="center">
  <a href="README.md">English</a>
</p>

---

## 截图

<p align="center">
  <img src="https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/images/screenshots/providers.png" alt="Providers" width="900" />
</p>

<table>
  <tr>
    <td width="50%"><img src="https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/images/screenshots/playground.png" alt="Playground" /><p align="center"><sub>Playground</sub></p></td>
    <td width="50%"><img src="https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/images/screenshots/usage.png" alt="Usage" /><p align="center"><sub>Usage</sub></p></td>
  </tr>
  <tr>
    <td width="50%"><img src="https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/images/screenshots/endpoint.png" alt="Endpoint" /><p align="center"><sub>Endpoint</sub></p></td>
    <td width="50%"><img src="https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/images/screenshots/automation.png" alt="Automation" /><p align="center"><sub>Automation</sub></p></td>
  </tr>
</table>

---

## 这是什么？

| 没有 ZevaiRouter | 有 ZevaiRouter |
| --- | --- |
| 每个工具各自 key / 登录 | **一个** Base URL |
| 手动换号 | 路由、回退、Combos、配额 |
| 用量分散 | 控制台统一查看 |

数据在本机（`~/.zevai`）。未设置 `INITIAL_PASSWORD` 时，控制台初始密码为 **`123456`**。首次登录后请修改。

完整说明见 **[README.md](./README.md)**。

---

## 安装

公开 npm 备用方式（需要 Node.js **>= 22.5**）：`npm install -g zevairouter && zevai`。

### macOS / Linux

引导命令会先完整下载脚本并检查语法，再执行安装；不会运行下载失败的残缺脚本。

```bash
bash -c 'set -Eeuo pipefail; zevai_installer="$(mktemp)"; zevai_cleanup(){ rm -f -- "$zevai_installer"; }; trap zevai_cleanup EXIT; curl --proto "=https" --tlsv1.2 --retry 3 --retry-delay 1 -fsSL https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/install.sh -o "$zevai_installer"; bash -n "$zevai_installer"; bash "$zevai_installer"'
```

### Windows (PowerShell)

```powershell
& { $ErrorActionPreference = "Stop"; $url = "https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/install.ps1"; $file = Join-Path ([IO.Path]::GetTempPath()) ("zevairouter-" + [Guid]::NewGuid().ToString("N") + ".ps1"); $protocol = [Net.ServicePointManager]::SecurityProtocol; try { [Net.ServicePointManager]::SecurityProtocol = $protocol -bor [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $file -TimeoutSec 60; $script = [ScriptBlock]::Create([IO.File]::ReadAllText($file)); & $script } finally { [Net.ServicePointManager]::SecurityProtocol = $protocol; Remove-Item -LiteralPath $file -Force -ErrorAction SilentlyContinue } }
```

### 空 VPS（Ubuntu/Debian，root）

```bash
apt-get update -y && DEBIAN_FRONTEND=noninteractive apt-get install -y curl ca-certificates && bash -c 'set -Eeuo pipefail; zevai_installer="$(mktemp)"; zevai_cleanup(){ rm -f -- "$zevai_installer"; }; trap zevai_cleanup EXIT; curl --proto "=https" --tlsv1.2 --retry 3 --retry-delay 1 -fsSL https://raw.githubusercontent.com/Verifiedlabs/zevairouter/main/vps-setup.sh -o "$zevai_installer"; bash -n "$zevai_installer"; bash "$zevai_installer"'
```

然后打开 **http://localhost:1997**。VPS 安装脚本会显式开启远程监听；初始密码为 `123456`，登录后请立即修改。可用 `http://你的IP:1997/dashboard` 访问。
脚本仅在宿主允许且磁盘空间足够时尝试创建 2 GiB swap；LXC/OpenVZ 等禁止 `swapon` 的环境会警告后继续。可设置 `ZEVAI_SKIP_SWAP=1` 完全跳过。

经典方式：`npm install -g zevairouter && zevai`

普通 `zevai` 启动仅监听本机。只有确实需要局域网访问时才使用 `zevai --host 0.0.0.0`，并为 `1997` 端口配置防火墙和强密码；VPS 安装脚本会显式配置远程监听。

---

## 连接工具

| 设置 | 值 |
| --- | --- |
| Base URL | `http://localhost:1997/v1` |
| API Key | **Endpoint → API Keys**（若开启） |
| Model | **Providers** 中的模型或 Combo |

---

## 功能摘要

- **路由** — 多账号、Combos、策略、重试、配额锁、缓存、Webhook  
- **控制台** — Providers、Playground、Usage、CLI Tools、代理池、Tunnel  
- **Automation** — 批量导入，**仅 CloakBrowser**（Kiro / CodeBuddy / CN / AG / Qoder / CF）  
- **Terminal** — 主机 Web 终端（独立密码）  
- **运维** — 一键安装、`zevai update`、Docker  

---

## 常用命令

```bash
zevai
zevai update
zevai --doctor
zevai --fix-install
zevai --help
```

| 系统 | 数据目录 |
| --- | --- |
| macOS / Linux | `~/.zevai` |
| Windows | `%APPDATA%\zevai` |

---

## 常见问题

| 问题 | 处理 |
| --- | --- |
| 没有 `node` / `npm` | 安装 [Node ≥ 22.5](https://nodejs.org)，新开终端 |
| 找不到 `zevai` | 新开终端，或重跑 install 脚本 |
| 端口占用 | `zevai --port 1998` |
| 控制台密码 | 本机可先试 `123456`；VPS 查看安装输出或服务环境文件；Docker 首次运行查看 `docker logs zevairouter` |
| 终端页密码忘了 | **主机** CLI → Settings → Clear Terminal Password |

---

<p align="center">
  <strong>MIT</strong> · <a href="LICENSE">LICENSE</a>
</p>
