Codex

整合狀態
  • 建議通訊協定: OpenAI Responses
  • 設定核對日期: 2026 年 7 月 15 日(Codex 官方設定參考文件)
  • 執行階段驗證: 待驗證

Codex 自訂提供者使用 Responses 通訊協定。請選擇支援 /v1/responses 的 GetRouter 模型。

儲存 API 金鑰

export GETROUTER_API_KEY="YOUR_API_KEY"

如有需要,請將其加入 Shell 的安全環境設定。請勿將金鑰直接寫入 config.toml

設定 Codex

編輯 ~/.codex/config.toml

model = "MODEL_ID"
model_provider = "getrouter"

[model_providers.getrouter]
name = "GetRouter"
base_url = "https://getrouter.ai/v1"
env_key = "GETROUTER_API_KEY"
wire_api = "responses"

MODEL_ID 替換為模型頁面中的確切模型 ID。請保留其他無關的 Codex 設定。

Warning

請勿使用 wire_api = "chat"。目前 Codex 自訂提供者使用 Responses。僅支援 Chat Completions 的模型不適用於此設定。

驗證

  1. 從已設定 GETROUTER_API_KEY 的 Shell 重新啟動 Codex。
  2. 確認 Codex 顯示預期的模型/提供者。
  3. 先詢問一個不會造成變更的儲存庫問題。
  4. 確認請求出現在 GetRouter 用量記錄中。
  5. 確認無誤後,再測試編輯、工具呼叫、長上下文或較高的推理設定。

常見錯誤

  • 缺少環境變數: 從已匯出 GETROUTER_API_KEY 的 Shell 啟動 Codex。
  • /responses 回傳 404: 使用 base_url = "https://getrouter.ai/v1";請勿自行附加 /responses
  • 找不到模型: 複製確切的模型 ID,並確認金鑰可使用該模型。
  • 不支援回應或工具事件: 所選模型/提供者路徑可能無法完整支援 Responses 工具事件;請測試其他支援 Responses 的模型。
  • Codex 仍使用其他提供者: 檢查使用中的設定檔與頂層 model_provider

分享診斷資訊前,請先參閱整合疑難排解