Integrations
Codex 集成
本教程介紹如何讓 Codex CLI 使用 ReachAPI 網關。
本文示例網關地址:https://direct.reachapi.ai/v1
說明:以下內容基於 2026-04-17 查閱的 OpenAI Codex 官方文檔整理。
1. 前置條件
開始前請先確認:
- 你已準備可用的 ReachAPI Key(例如:
sk-xxxxxx) - 網關支持 Responses API
- 本機已安裝 Node.js(建議 LTS)
2. Windows(推薦 PowerShell)
2.1 安裝 Codex CLI
npm install -g @openai/codex
codex --version2.2 一鍵寫入配置
# 創建目錄
New-Item -ItemType Directory -Force "$HOME\.codex" | Out-Null
# 創建 config.toml
@'
model_provider = "reachapi"
model = "gpt-5.4"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"
[model_providers.reachapi]
name = "reachapi"
base_url = "https://direct.reachapi.ai/v1"
wire_api = "responses"
requires_openai_auth = true
'@ | Set-Content -Path "$HOME\.codex\config.toml" -Encoding utf8
# 創建 auth.json
@'
{
"OPENAI_API_KEY": "YOUR_REACH_API_KEY"
}
'@ | Set-Content -Path "$HOME\.codex\auth.json" -Encoding utf82.3 驗證是否生效
codex輸入測試提示詞:
只回復:Codex 網關連接成功3. macOS / Linux / WSL
3.1 安裝 Codex CLI
npm install -g @openai/codex
codex --versionmacOS 也可選 Homebrew:
brew install codex3.2 一鍵寫入配置
mkdir -p ~/.codex
# 創建 config.toml
cat > ~/.codex/config.toml << 'EOF'
model_provider = "reachapi"
model = "gpt-5.4"
model_reasoning_effort = "high"
disable_response_storage = true
preferred_auth_method = "apikey"
[model_providers.reachapi]
name = "reachapi"
base_url = "https://direct.reachapi.ai/v1"
wire_api = "responses"
requires_openai_auth = true
EOF
# 創建 auth.json
cat > ~/.codex/auth.json << 'EOF'
{
"OPENAI_API_KEY": "YOUR_REACH_API_KEY"
}
EOF把
YOUR_REACH_API_KEY替換爲你的真實 Key。
3.3 驗證是否生效
codex輸入測試提示詞:
只回復:Codex 網關連接成功4. 常見問題排查
401 / 403 鑑權失敗
- 檢查
auth.json中的 Key 是否正確 - 檢查 Key 是否過期、是否有對應模型權限
404 / Not Found
- 檢查
base_url是否爲https://direct.reachapi.ai/v1 - 檢查
wire_api = "responses"是否正確
模型不存在 / model not found
- 把
model = "gpt-5.4"改爲你網關實際開通的模型 ID
Windows 下命令執行異常
- 建議優先使用 PowerShell
- 若提示權限或執行策略問題,可嘗試管理員 PowerShell
5. 官方參考
- Codex 快速開始: https://developers.openai.com/codex/quickstart
- Codex 認證說明: https://developers.openai.com/codex/auth
- Codex 配置基礎: https://developers.openai.com/codex/config-basic
- Codex 配置參考: https://developers.openai.com/codex/config-reference
- OpenAI Codex GitHub 說明: https://github.com/openai/codex