使用范围与要求
KHapiMAN 用于在终端中管理 KHaiXAPI Profile,并把 Profile 应用到支持的编码客户端。使用前准备 Node.js 22 或更高版本、npm,以及一个可用的 KHaiXAPI API Key。
| 项目 | 要求 |
|---|---|
| 运行环境 | Windows、macOS 或 Linux,Node.js 22+ 与 npm |
| 服务地址 | https://api.khaix.net |
| 可配置客户端 | Codex CLI、Claude Code、OpenCode、Aider |
安装与启动工作台
在终端全局安装后启动 KHapiMAN:
npm install --global khapiman
khapiman --version
khapiman使用方向键或 j/k 移动,按 Enter 确认,按 Esc 返回。工作台中的 API Profiles、Clients 和 Changes 分别用于管理配置、选择客户端和查看变更。
创建 Profile
打开 API Profiles,创建一个名称易于识别的 Profile,填写 https://api.khaix.net 和 API Key,然后加载当前 Key 可用的模型。
| 客户端 | 协议 | 配置文件 |
|---|---|---|
| Codex CLI | openai-responses | ~/.codex/config.toml |
| Claude Code | anthropic-messages | ~/.claude/settings.json |
| OpenCode | openai-chat | ~/.config/opencode/opencode.json |
| Aider | openai-chat | ~/.aider.conf.yml |
为 Profile 选择实际使用的协议和模型后保存。一个 Profile 可按协议供多个客户端使用。
完成配置
- 在控制台创建 API Key,并确认目标模型可用。
- 进入 API Profiles,填写名称、服务地址和 API Key。
- 选择模型与协议,等待 Profile 测试完成。
- 进入 Clients,选择要配置的客户端和对应 Profile。
- 先运行
khapiman install --dry-run查看命令,再确认应用配置。 - 在 Changes 中确认目标文件和变更内容,然后选择 Apply。
khapiman doctor
khapiman status
khapiman profile list应用并启动客户端
配置应用完成后,在终端使用对应命令启动客户端:
| 客户端 | 命令 |
|---|---|
| Codex CLI | codex |
| Claude Code | khapiman run claude |
| OpenCode | khapiman run opencode |
| Aider | khapiman run aider |
khapiman apply primary --tool codex --model responses-model
khapiman apply primary --tool opencode aider --model chat-model
khapiman apply primary --tool claude常用命令
工作台提供状态、诊断、Profile 列表和连通性测试命令,遇到配置变化后可重新运行。
khapiman status
khapiman doctor
khapiman profile list
khapiman test <profile>更新与卸载
需要更新时重新安装全局包;不再使用时先退出客户端,再卸载 KHapiMAN。
npm update --global khapiman
npm uninstall --global khapiman重新安装后再次运行 khapiman --version,并在工作台中检查 Profile 和客户端列表。