跳到主要内容
Router One
Router One

CLI 配置指南

Claude Code、Codex CLI 一键接入,以及 OpenClaw、Hermes Agent 的手动配置步骤。

一键接入(推荐)

一条命令完成安装 CLI、写入网关配置、并用 1 token 测试请求验证 Key。已有配置文件会自动备份。

Key 只在浏览器本地拼进命令,不会被上传。

bash
curl -fsSL https://router.one/install/claude-code.sh | bash -s -- sk-your-api-key

配置立即生效,运行 claude 即可开始使用。

powershell
$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

bash
curl -fsSL https://router.one/install/codex.sh | bash -s -- sk-your-api-key

新开的终端可直接运行 codex;当前终端先执行 source ~/.zshrc(或对应 shell 配置)。

powershell
$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 作为代理,享受统一路由、成本管控和完整可观测性。

开始之前,请先在 Dashboard API Keys 页面创建你的 API Key(格式: sk-xxx)。
1

通过 Homebrew 安装 Node.js

Claude Code CLI 需要 Node.js 18 或更高版本。

bash
brew install node
bash
node --version
2

全局安装 Claude Code CLI

bash
npm install -g @anthropic-ai/claude-code
3

配置环境变量

将 Router One 设为 Claude Code 的 API 代理端点。

如果你之前使用过官方 Claude CLI,建议先清除旧配置以避免冲突: rm -rf ~/.claude

临时设置(仅当前终端会话有效):

bash
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export ANTHROPIC_BASE_URL=https://api.router.one' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc
ANTHROPIC_AUTH_TOKEN 会以 Authorization: Bearer 发送给网关,无需再设置 ANTHROPIC_API_KEY。注意:一键脚本会把同样的配置写进 ~/.claude/settings.json 的 env 块,其优先级高于 shell 环境变量;更换 Key 时优先更新 settings.json,或直接重跑一键命令。
4

启动 Claude Code

运行以下命令启动 CLI:

bash
claude
1

安装 Node.js

从 Node.js 官网下载安装,或使用 winget。

powershell
winget install OpenJS.NodeJS.LTS
powershell
node --version
2

全局安装 Claude Code CLI

powershell
npm install -g @anthropic-ai/claude-code
3

配置环境变量

将 Router One 设为 Claude Code 的 API 代理端点。

如果你之前使用过官方 Claude CLI,建议先清除旧配置以避免冲突: Remove-Item -Recurse -Force ~\.claude

临时设置(仅当前 PowerShell 会话有效):

powershell
$env:ANTHROPIC_BASE_URL = "https://api.router.one"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-api-key"

永久设置(系统环境变量):

powershell
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.router.one", "User")
[System.Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk-your-api-key", "User")
ANTHROPIC_AUTH_TOKEN 会以 Authorization: Bearer 发送给网关,无需再设置 ANTHROPIC_API_KEY。注意:一键脚本会把同样的配置写进 ~/.claude/settings.json 的 env 块,其优先级高于 shell 环境变量;更换 Key 时优先更新 settings.json,或直接重跑一键命令。
4

启动 Claude Code

运行以下命令启动 CLI:

powershell
claude
1

安装 Node.js

使用包管理器或 nvm 安装 Node.js 18+。

通过 nvm(推荐):

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
node --version

或通过 apt(Debian/Ubuntu):

bash
sudo apt update && sudo apt install -y nodejs npm
2

全局安装 Claude Code CLI

bash
npm install -g @anthropic-ai/claude-code
3

配置环境变量

将 Router One 设为 Claude Code 的 API 代理端点。

如果你之前使用过官方 Claude CLI,建议先清除旧配置以避免冲突: rm -rf ~/.claude

临时设置(仅当前终端会话有效):

bash
export ANTHROPIC_BASE_URL=https://api.router.one
export ANTHROPIC_AUTH_TOKEN=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export ANTHROPIC_BASE_URL=https://api.router.one' >> ~/.bashrc
echo 'export ANTHROPIC_AUTH_TOKEN=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc
ANTHROPIC_AUTH_TOKEN 会以 Authorization: Bearer 发送给网关,无需再设置 ANTHROPIC_API_KEY。注意:一键脚本会把同样的配置写进 ~/.claude/settings.json 的 env 块,其优先级高于 shell 环境变量;更换 Key 时优先更新 settings.json,或直接重跑一键命令。
4

启动 Claude Code

运行以下命令启动 CLI:

bash
claude

Codex CLI 配置指南

配置 OpenAI Codex CLI 使用 Router One 作为代理,享受统一路由、成本管控和完整可观测性。

开始之前,请先在 Dashboard API Keys 页面创建你的 API Key(格式: sk-xxx)。
1

通过 Homebrew 安装 Node.js

Codex CLI 需要 Node.js 16 或更高版本。

bash
brew install node
bash
node --version
2

全局安装 Codex CLI

bash
npm install -g @openai/codex
3

配置环境变量

将 Router One 设为 Codex 的 API 代理端点。

临时设置(仅当前终端会话有效):

bash
export ROUTER_ONE_API_KEY=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export ROUTER_ONE_API_KEY=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc
4

创建 Codex 配置文件

将以下内容写入 ~/.codex/config.toml,启用 Router One 作为模型 provider。

bash
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
5

启动 Codex

运行以下命令启动 CLI:

bash
codex
1

安装 Node.js

从 Node.js 官网下载安装,或使用 winget。

powershell
winget install OpenJS.NodeJS.LTS
powershell
node --version
2

全局安装 Codex CLI

powershell
npm install -g @openai/codex
3

配置环境变量

将 Router One 设为 Codex 的 API 代理端点。

临时设置(仅当前 PowerShell 会话有效):

powershell
$env:ROUTER_ONE_API_KEY = "sk-your-api-key"

永久设置(系统环境变量):

powershell
[System.Environment]::SetEnvironmentVariable("ROUTER_ONE_API_KEY", "sk-your-api-key", "User")
4

创建 Codex 配置文件

将以下内容写入 %USERPROFILE%\.codex\config.toml,启用 Router One 作为模型 provider。

powershell
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)))
5

启动 Codex

运行以下命令启动 CLI:

powershell
codex
1

安装 Node.js

使用包管理器或 nvm 安装 Node.js 16+。

通过 nvm(推荐):

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --lts
node --version

或通过 apt(Debian/Ubuntu):

bash
sudo apt update && sudo apt install -y nodejs npm
2

全局安装 Codex CLI

bash
npm install -g @openai/codex
3

配置环境变量

将 Router One 设为 Codex 的 API 代理端点。

临时设置(仅当前终端会话有效):

bash
export ROUTER_ONE_API_KEY=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export ROUTER_ONE_API_KEY=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc
4

创建 Codex 配置文件

将以下内容写入 ~/.codex/config.toml,启用 Router One 作为模型 provider。

bash
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
5

启动 Codex

运行以下命令启动 CLI:

bash
codex

OpenClaw CLI 配置指南

配置 OpenClaw 使用 Router One 作为自定义 OpenAI 兼容 provider,代理 agent 的模型调用。

开始之前,请先在 Dashboard API Keys 页面创建你的 API Key(格式: sk-xxx)。
1

通过 Homebrew 安装 Node.js

OpenClaw CLI 需要 Node.js 22.14.0 或更高版本。

bash
brew install node
bash
node --version
2

全局安装 OpenClaw CLI

bash
npm install -g openclaw@latest
3

配置环境变量

将 Router One 设为 OpenClaw 的 API 代理端点。

临时设置(仅当前终端会话有效):

bash
export CUSTOM_API_KEY=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export CUSTOM_API_KEY=sk-your-api-key' >> ~/.zshrc
source ~/.zshrc
4

运行 OpenClaw onboarding

将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。

bash
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
5

启动 OpenClaw

运行以下命令启动 CLI:

bash
openclaw
1

安装 Node.js

从 Node.js 官网下载安装,或使用 winget。

powershell
winget install OpenJS.NodeJS.LTS
powershell
node --version
2

全局安装 OpenClaw CLI

powershell
npm install -g openclaw@latest
3

配置环境变量

将 Router One 设为 OpenClaw 的 API 代理端点。

临时设置(仅当前 PowerShell 会话有效):

powershell
$env:CUSTOM_API_KEY = "sk-your-api-key"

永久设置(系统环境变量):

powershell
[System.Environment]::SetEnvironmentVariable("CUSTOM_API_KEY", "sk-your-api-key", "User")
4

运行 OpenClaw onboarding

将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。

powershell
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
5

启动 OpenClaw

运行以下命令启动 CLI:

powershell
openclaw
1

安装 Node.js

使用包管理器或 nvm 安装 Node.js 22.14.0+。

通过 nvm(推荐):

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 24
node --version

或通过 apt(Debian/Ubuntu):

bash
sudo apt update && sudo apt install -y nodejs npm
2

全局安装 OpenClaw CLI

bash
npm install -g openclaw@latest
3

配置环境变量

将 Router One 设为 OpenClaw 的 API 代理端点。

临时设置(仅当前终端会话有效):

bash
export CUSTOM_API_KEY=sk-your-api-key

永久设置(写入 shell 配置文件):

bash
echo 'export CUSTOM_API_KEY=sk-your-api-key' >> ~/.bashrc
source ~/.bashrc
4

运行 OpenClaw onboarding

将 Router One 注册为自定义 OpenAI 兼容 provider,并安装本地 daemon。

bash
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
5

启动 OpenClaw

运行以下命令启动 CLI:

bash
openclaw

OpenClaw 完整接入指南 →

Hermes Agent 配置指南

配置 Hermes Agent 使用 Router One 作为自定义 OpenAI 兼容端点,并将模型设置持久化。

开始之前,请先在 Dashboard API Keys 页面创建你的 API Key(格式: sk-xxx)。
1

安装 Python 和 pip

Hermes Agent 通过 pip 安装。Windows 用户建议在 WSL2 内运行 Hermes。

bash
brew install python
python3 --version
python3 -m pip --version
bash
node --version
2

全局安装 Hermes Agent CLI

bash
pip install hermes-agent
hermes postinstall
3

创建 Hermes 配置文件

将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。

bash
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 不读取 OPENAI_BASE_URL。请使用 hermes model,或直接编辑 ~/.hermes/config.yaml。
4

启动 Hermes Agent

运行以下命令启动 CLI:

bash
hermes
1

安装 WSL2

先安装 WSL2,然后在 WSL2 终端内执行后续 Hermes 命令。

powershell
wsl --install
powershell
node --version
2

全局安装 Hermes Agent CLI

bash
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
source ~/.bashrc
3

创建 Hermes 配置文件

将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。

bash
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 不读取 OPENAI_BASE_URL。请使用 hermes model,或直接编辑 ~/.hermes/config.yaml。
4

启动 Hermes Agent

运行以下命令启动 CLI:

bash
hermes
1

安装 Python 和 pip

Hermes Agent 通过 pip 安装。Windows 用户建议在 WSL2 内运行 Hermes。

bash
python3 --version
python3 -m pip --version

或通过 apt(Debian/Ubuntu):

bash
sudo apt update && sudo apt install -y python3 python3-pip
2

全局安装 Hermes Agent CLI

bash
pip install hermes-agent
hermes postinstall
3

创建 Hermes 配置文件

将以下内容写入 ~/.hermes/config.yaml,把 Router One 持久化为自定义端点。

bash
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 不读取 OPENAI_BASE_URL。请使用 hermes model,或直接编辑 ~/.hermes/config.yaml。
4

启动 Hermes Agent

运行以下命令启动 CLI:

bash
hermes