TeamoRouter 接入 Codex命令行

Codex 是 OpenAI 官方推出的运行在终端中的 AI 编程助手,本章为安装教程。如果您已安装 Codex ,在 Codex 中接入 TeamoRouter 请参考下一章。

一、从零安装 Codex

安装 Codex

  • 推荐安装 Node.js 22+(或使用 Homebrew / 官方 installer)。

  • macOS 用户也可以直接使用 Homebrew 安装:brew install codex
  • 在命令行界面,执行以下命令安装 Codex :
plaintext
npm install -g @openai/codex
  • 安装结束后,执行以下命令,若显示版本号则安装成功:
plaintext
codex --version

配置 Provider

macOS / Linux 用户

打开终端,把下面整段粘进去回车:

plaintext
mkdir -p ~/.codex && cat > ~/.codex/config.toml <<'EOF'
model_provider = "teamorouter"
model = "gpt-5.4"
model_reasoning_effort = "high"
[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.com/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
EOF
Windows 用户

打开 PowerShell(开始菜单搜「PowerShell」),把下面整段粘进去回车:

plaintext
New-Item -ItemType Directory -Force -Path "$HOME\.codex" | Out-Null
@'
model_provider = "teamorouter"
model = "gpt-5.4"
model_reasoning_effort = "high"

[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.com/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
'@ | Set-Content -Path "$HOME\.codex\config.toml" -Encoding UTF8

设置 API Key

把下面命令里的 <你的-TeamoRouter-key> 替换成你自己创建的API Key,API Key 在 TeamoRouter 控制台 获取。然后粘到终端执行。

macOS 用户
plaintext
echo 'export OPENAI_API_KEY="<你的-TeamoRouter-key>"' >> ~/.zshrc
source ~/.zshrc
Linux 用户
plaintext
echo 'export OPENAI_API_KEY="<你的-TeamoRouter-key>"' >> ~/.bashrc
source ~/.bashrc
Windows 用户
plaintext
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "<你的-TeamoRouter-key>", "User")

Windows 用户:执行完上面命令后,关闭当前 PowerShell 窗口重新打开一次才能生效。

三步都做完后,在终端执行 codex 就会走 TeamoRouter。

二、已经安装 Codex ,修改配置

如果你已经安装了Codex ,只需修改以下环境变量,其中 API Key 在 TeamoRouter 控制台 获取。

配置 Provider

macOS / Linux 用户

打开终端,把下面整段粘进去回车:

plaintext
mkdir -p ~/.codex && cat > ~/.codex/config.toml <<'EOF'
model_provider = "teamorouter"
model = "gpt-5.4"
model_reasoning_effort = "high"
[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.com/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
EOF
Windows 用户

打开 PowerShell(开始菜单搜「PowerShell」),把下面整段粘进去回车:

plaintext
New-Item -ItemType Directory -Force -Path "$HOME\.codex" | Out-Null
@'
model_provider = "teamorouter"
model = "gpt-5.4"
model_reasoning_effort = "high"

[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.com/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
'@ | Set-Content -Path "$HOME\.codex\config.toml" -Encoding UTF8

设置 API Key

把下面命令里的 <你的-TeamoRouter-key> 替换成你刚才在 Dashboard 复制的那串,然后粘到终端执行。

macOS 用户
plaintext
echo 'export OPENAI_API_KEY="<你的-TeamoRouter-key>"' >> ~/.zshrc
source ~/.zshrc
Linux 用户
plaintext
echo 'export OPENAI_API_KEY="<你的-TeamoRouter-key>"' >> ~/.bashrc
source ~/.bashrc
Windows 用户
plaintext
[Environment]::SetEnvironmentVariable("OPENAI_API_KEY", "<你的-TeamoRouter-key>", "User")

Windows 用户:执行完上面命令后,关闭当前 PowerShell 窗口重新打开一次才能生效。

两步都做完后,在终端执行 codex 就会走 TeamoRouter。

准备好了?三步即可开始登录控制台 · 购买额度 · 创建 API Key
微信扫码加入交流群
遇到问题?微信扫码加入交流群
TeamoRouter 接入 Codex命令行 · 帮助文档