CLI 配置指南
Claude Code、Codex CLI 一键接入,以及 OpenClaw、Hermes Agent 的手动配置步骤。
一键接入(推荐)
一条命令完成安装 CLI、写入网关配置、并用 1 token 测试请求验证 Key。已有配置文件会自动备份。
Key 只在浏览器本地拼进命令,不会被上传。
curl -fsSL https://router.one/install/claude-code.sh | bash -s -- sk-your-api-key配置立即生效,运行 claude 即可开始使用。
$env:ROUTER_ONE_API_KEY = "sk-your-api-key"; irm https://router.one/install/claude-code.ps1 | iex配置立即生效,运行 claude 即可开始使用。
运行前可先查看脚本源码: /install/claude-code.sh · /install/claude-code.ps1
curl -fsSL https://router.one/install/codex.sh | bash -s -- sk-your-api-key新开的终端可直接运行 codex;当前终端先执行 source ~/.zshrc(或对应 shell 配置)。
$env:ROUTER_ONE_API_KEY = "sk-your-api-key"; irm https://router.one/install/codex.ps1 | iex当前会话已生效,直接运行 codex 即可。
运行前可先查看脚本源码: /install/codex.sh · /install/codex.ps1
手动配置
想了解每一步做了什么、或需要自定义时,按下面的步骤手动配置。
Claude Code CLI 配置指南
配置 Claude Code CLI 使用 Router One 作为代理,享受统一路由、成本管控和完整可观测性。
sk-xxx)。通过 Homebrew 安装 Node.js
Claude Code CLI 需要 Node.js 18 或更高版本。
brew install nodenode --version全局安装 Claude Code CLI
npm install -g @anthropic-ai/claude-code配置环境变量
将 Router One 设为 Claude Code 的 API 代理端点。
rm -rf ~/.claude临时设置(仅当前终端会话有效):
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export ANTHROPIC_BASE_URL=https://api.router.one' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc启动 Claude Code
运行以下命令启动 CLI:
claude安装 Node.js
从 Node.js 官网下载安装,或使用 winget。
winget install OpenJS.NodeJS.LTSnode --version全局安装 Claude Code CLI
npm install -g @anthropic-ai/claude-code配置环境变量
将 Router One 设为 Claude Code 的 API 代理端点。
Remove-Item -Recurse -Force ~\.claude临时设置(仅当前 PowerShell 会话有效):
$env:ANTHROPIC_BASE_URL = "https://api.router.one"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-api-key"永久设置(系统环境变量):
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.router.one", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-your-api-key", "User")启动 Claude Code
运行以下命令启动 CLI:
claude安装 Node.js
使用包管理器或 nvm 安装 Node.js 18+。
通过 nvm(推荐):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
node --version或通过 apt(Debian/Ubuntu):
sudo apt update && sudo apt install -y nodejs npm全局安装 Claude Code CLI
npm install -g @anthropic-ai/claude-code配置环境变量
将 Router One 设为 Claude Code 的 API 代理端点。
rm -rf ~/.claude临时设置(仅当前终端会话有效):
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export ANTHROPIC_BASE_URL=https://api.router.one' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc启动 Claude Code
运行以下命令启动 CLI:
claudeCodex CLI 配置指南
配置 OpenAI Codex CLI 使用 Router One 作为代理,享受统一路由、成本管控和完整可观测性。
sk-xxx)。通过 Homebrew 安装 Node.js
Codex CLI 需要 Node.js 16 或更高版本。
brew install nodenode --version全局安装 Codex CLI
npm install -g @openai/codex配置环境变量
将 Router One 设为 Codex 的 API 代理端点。
临时设置(仅当前终端会话有效):
export ROUTER_ONE_API_KEY=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export ROUTER_ONE_API_KEY=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc创建 Codex 配置文件
将以下内容写入 ~/.codex/config.toml,启用 Router One 作为模型 provider。
mkdir -p ~/.codex && cat > ~/.codex/config.toml <<'EOF'
model = "gpt-5.6-sol"
model_provider = "router"
model_reasoning_effort = "high"
model_verbosity = "high"
web_search = "live"
[model_providers.router]
base_url = "https://api.router.one/v1"
env_key = "ROUTER_ONE_API_KEY"
env_key_instructions = "Create an API key at https://router.one/dashboard/api-keys and set the ROUTER_ONE_API_KEY environment variable."
name = "Router One"
wire_api = "responses"
EOF启动 Codex
运行以下命令启动 CLI:
codex安装 Node.js
从 Node.js 官网下载安装,或使用 winget。
winget install OpenJS.NodeJS.LTSnode --version全局安装 Codex CLI
npm install -g @openai/codex配置环境变量
将 Router One 设为 Codex 的 API 代理端点。
临时设置(仅当前 PowerShell 会话有效):
$env:ROUTER_ONE_API_KEY = "sk-your-api-key"永久设置(系统环境变量):
[System.Environment]::SetEnvironmentVariable("ROUTER_ONE_API_KEY", "sk-your-api-key", "User")创建 Codex 配置文件
将以下内容写入 %USERPROFILE%\.codex\config.toml,启用 Router One 作为模型 provider。
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null
$config = @'
model = "gpt-5.6-sol"
model_provider = "router"
model_reasoning_effort = "high"
model_verbosity = "high"
web_search = "live"
[model_providers.router]
base_url = "https://api.router.one/v1"
env_key = "ROUTER_ONE_API_KEY"
env_key_instructions = "Create an API key at https://router.one/dashboard/api-keys and set the ROUTER_ONE_API_KEY environment variable."
name = "Router One"
wire_api = "responses"
'@
[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, (New-Object System.Text.UTF8Encoding($false)))启动 Codex
运行以下命令启动 CLI:
codex安装 Node.js
使用包管理器或 nvm 安装 Node.js 16+。
通过 nvm(推荐):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
node --version或通过 apt(Debian/Ubuntu):
sudo apt update && sudo apt install -y nodejs npm全局安装 Codex CLI
npm install -g @openai/codex配置环境变量
将 Router One 设为 Codex 的 API 代理端点。
临时设置(仅当前终端会话有效):
export ROUTER_ONE_API_KEY=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export ROUTER_ONE_API_KEY=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc创建 Codex 配置文件
将以下内容写入 ~/.codex/config.toml,启用 Router One 作为模型 provider。
mkdir -p ~/.codex && cat > ~/.codex/config.toml <<'EOF'
model = "gpt-5.6-sol"
model_provider = "router"
model_reasoning_effort = "high"
model_verbosity = "high"
web_search = "live"
[model_providers.router]
base_url = "https://api.router.one/v1"
env_key = "ROUTER_ONE_API_KEY"
env_key_instructions = "Create an API key at https://router.one/dashboard/api-keys and set the ROUTER_ONE_API_KEY environment variable."
name = "Router One"
wire_api = "responses"
EOF启动 Codex
运行以下命令启动 CLI:
codexOpenClaw CLI 配置指南
配置 OpenClaw 使用 Router One 作为自定义 OpenAI 兼容 provider,代理 agent 的模型调用。
sk-xxx)。通过 Homebrew 安装 Node.js
OpenClaw CLI 需要 Node.js 22.14.0 或更高版本。
brew install nodenode --version全局安装 OpenClaw CLI
npm install -g openclaw@latest配置环境变量
将 Router One 设为 OpenClaw 的 API 代理端点。
临时设置(仅当前终端会话有效):
export CUSTOM_API_KEY=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export CUSTOM_API_KEY=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc运行 OpenClaw onboarding
将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。
openclaw onboard --non-interactive \
--auth-choice custom-api-key \
--custom-base-url https://api.router.one/v1 \
--custom-model-id gpt-5.6-sol \
--custom-provider-id router-one \
--custom-compatibility openai \
--install-daemon启动 OpenClaw
运行以下命令启动 CLI:
openclaw安装 Node.js
从 Node.js 官网下载安装,或使用 winget。
winget install OpenJS.NodeJS.LTSnode --version全局安装 OpenClaw CLI
npm install -g openclaw@latest配置环境变量
将 Router One 设为 OpenClaw 的 API 代理端点。
临时设置(仅当前 PowerShell 会话有效):
$env:CUSTOM_API_KEY = "sk-your-api-key"永久设置(系统环境变量):
[System.Environment]::SetEnvironmentVariable("CUSTOM_API_KEY", "sk-your-api-key", "User")运行 OpenClaw onboarding
将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。
openclaw onboard --non-interactive `
--auth-choice custom-api-key `
--custom-base-url https://api.router.one/v1 `
--custom-model-id gpt-5.6-sol `
--custom-provider-id router-one `
--custom-compatibility openai `
--install-daemon启动 OpenClaw
运行以下命令启动 CLI:
openclaw安装 Node.js
使用包管理器或 nvm 安装 Node.js 22.14.0+。
通过 nvm(推荐):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 24
node --version或通过 apt(Debian/Ubuntu):
sudo apt update && sudo apt install -y nodejs npm全局安装 OpenClaw CLI
npm install -g openclaw@latest配置环境变量
将 Router One 设为 OpenClaw 的 API 代理端点。
临时设置(仅当前终端会话有效):
export CUSTOM_API_KEY=sk-your-api-key永久设置(写入 shell 配置文件):
echo 'export CUSTOM_API_KEY=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc运行 OpenClaw onboarding
将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。
openclaw onboard --non-interactive \
--auth-choice custom-api-key \
--custom-base-url https://api.router.one/v1 \
--custom-model-id gpt-5.6-sol \
--custom-provider-id router-one \
--custom-compatibility openai \
--install-daemon启动 OpenClaw
运行以下命令启动 CLI:
openclawHermes Agent 配置指南
配置 Hermes Agent 使用 Router One 作为自定义 OpenAI 兼容端点,并将模型设置持久化。
sk-xxx)。安装 Python 和 pip
Hermes Agent 通过 pip 安装。Windows 用户建议在 WSL2 内运行 Hermes。
brew install python
python3 --version
python3 -m pip --versionnode --version全局安装 Hermes Agent CLI
pip install hermes-agent
hermes postinstall创建 Hermes 配置文件
将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。
mkdir -p ~/.hermes && cat > ~/.hermes/config.yaml <<'EOF'
model:
provider: custom
default: gpt-5.6-sol
base_url: https://api.router.one/v1
api_key: sk-your-api-key
context_length: 65536
EOF启动 Hermes Agent
运行以下命令启动 CLI:
hermes安装 WSL2
先安装 WSL2,然后在 WSL2 终端内执行后续 Hermes 命令。
wsl --installnode --version全局安装 Hermes Agent CLI
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
source ~/.bashrc创建 Hermes 配置文件
将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。
mkdir -p ~/.hermes && cat > ~/.hermes/config.yaml <<'EOF'
model:
provider: custom
default: gpt-5.6-sol
base_url: https://api.router.one/v1
api_key: sk-your-api-key
context_length: 65536
EOF启动 Hermes Agent
运行以下命令启动 CLI:
hermes安装 Python 和 pip
Hermes Agent 通过 pip 安装。Windows 用户建议在 WSL2 内运行 Hermes。
python3 --version
python3 -m pip --version或通过 apt(Debian/Ubuntu):
sudo apt update && sudo apt install -y python3 python3-pip全局安装 Hermes Agent CLI
pip install hermes-agent
hermes postinstall创建 Hermes 配置文件
将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。
mkdir -p ~/.hermes && cat > ~/.hermes/config.yaml <<'EOF'
model:
provider: custom
default: gpt-5.6-sol
base_url: https://api.router.one/v1
api_key: sk-your-api-key
context_length: 65536
EOF启动 Hermes Agent
运行以下命令启动 CLI:
hermes