Codex Desktop 串接 OpenRouter 設定
Codex Desktop 串接 OpenRouter 設定
架構
Codex Desktop
↓
CCSwitch
↓
OpenRouter
↓
指定模型(例如 stealth/ox-alpha)
1. 保留 Codex 官方登入
安裝 CCSwitch:
brew install --cask cc-switch
Github: https://github.com/farion1231/cc-switch
先在 CCSwitch 開啟:
Settings
→ Codex App Enhancements
→ Keep official login for direct switches
→ ON
用途:
- 保留 Codex Desktop 的 ChatGPT 官方登入
- 模型請求則改走 OpenRouter
- 不需要重新登入 Codex Desktop
OpenAI Official在切換到 OpenRouter 後顯示 inactive 是正常的。
2. 建立 OpenRouter Provider
CCSwitch → Codex → 新增 Provider。
建議設定:
| 欄位 | 設定 |
|---|---|
| Name | OpenRouter |
| Base URL | https://openrouter.ai/api/v1 |
| API Key | OpenRouter API Key |
| Model | 例如 stealth/ox-alpha |
| Wire API | responses |
| Local Routing | OFF |
OpenRouter 原生支援 Responses API,所以通常不需要 Local Routing。
3. Ox Alpha 範例
Provider: OpenRouter
Base URL: https://openrouter.ai/api/v1
Model: stealth/ox-alpha
Wire API: responses
Local Routing: OFF
如果 CCSwitch 有 Context Window 設定,可使用:
Context Window: 1000000
Auto Compact: 900000
Reasoning 可先使用:
high
需要較強推理時再調成:
xhigh
4. 啟用 Provider
在 CCSwitch:
OpenRouter
→ Enable
此時:
OpenAI Official
→ inactive
OpenRouter
→ active
這是正常狀態。
Keep official login for direct switches 只負責保留登入狀態,不代表模型仍然走 OpenAI。
5. 重啟 Codex Desktop
完全關閉:
Cmd + Q
再重新啟動 Codex Desktop。
Provider / Model 設定通常需要重新啟動後才會完整載入。
6. 驗證設定
檢查 Codex config:
grep -E 'model|model_provider|base_url|wire_api' ~/.codex/config.toml
應看到類似:
model = "stealth/ox-alpha"
model_provider = "openrouter"
[model_providers.openrouter]
base_url = "https://openrouter.ai/api/v1"
wire_api = "responses"
實際內容以 CCSwitch 產生的設定為準。
MCP 顯示 Auth: Unsupported
這通常與 OpenRouter 無關。
例如:
MCP Server
Auth: Unsupported
Tools:
tool-a
tool-b
如果 Tools 有正常列出、也可以呼叫,代表 MCP 通常是正常的。
Auth: Unsupported 多半只是代表:
此 MCP 不支援 Codex 的 OAuth login flow
不代表:
MCP 連線失敗
可使用:
codex mcp list
或 Codex Desktop:
/mcp
確認 MCP tools 是否正常載入。
最終推薦設定
Keep official login for direct switches: ON
Provider:
OpenRouter
Base URL:
https://openrouter.ai/api/v1
Model:
stealth/ox-alpha
Wire API:
responses
Local Routing:
OFF
這樣 Codex Desktop 可以保留官方 ChatGPT 登入,同時實際模型請求透過 OpenRouter 執行。
相關筆記
- macOS 清理 Codex / Claude Code / OpenCode Worktree 指南 — 清理 Coding Agent 產生的 Worktree 與磁碟空間。