# 配置模型供应商 Source: https://ofox.ai/zh/docs/integrations/codex/model-provider 推荐使用 [CC Switch](https://github.com/farion1231/cc-switch?utm=ofox_ai) 完成配置 —— 一款开源的供应商管理工具,可视化操作,无需手动编辑 JSON 或环境变量。 > **使用 Ofox Desktop 更快完成配置。** 在 Apple 芯片 Mac 上,Desktop 可以检测此工具、备份现有配置,并应用 Ofox API Key 和兼容模型。[打开 Ofox Desktop](https://ofox.ai/zh/desktop)。 ## 1. 安装 CC Switch ### macOS ```bash brew install --cask cc-switch ``` 或前往 [Releases](https://github.com/farion1231/cc-switch/releases?utm=ofox_ai) 下载 `.dmg` 手动安装。 ### Windows 前往 [Releases](https://github.com/farion1231/cc-switch/releases?utm=ofox_ai) 下载 `.msi` 安装程序。 ### Linux ```bash # Debian / Ubuntu sudo dpkg -i CC-Switch-*.deb # Fedora / RHEL sudo rpm -i CC-Switch-*.rpm # AppImage chmod +x CC-Switch-*.AppImage && ./CC-Switch-*.AppImage ``` 支持 macOS 12+、Windows 10+、Ubuntu 22.04+ / Debian 11+ / Fedora 34+ ## 2. 添加 OfoxAI 供应商 ### 步骤一:新增供应商 切换到顶部 **Codex** 标签页,点击右上角 **+** 按钮。 ![CC Switch Codex 标签页](https://ofox.ai/images/integrations/cc-switch-codex-step1.png) ### 步骤二:填写配置 按下表填写,点击 **+ 添加** 完成。 ![CC Switch Codex 供应商配置](https://ofox.ai/images/integrations/cc-switch-codex-config.png) | 配置项 | 值 | 说明 | | --- | --- | --- | | ❶ 供应商名称 | `ofoxai-codex` | 自定义,方便识别 | | ❷ 官网链接 | `https://ofox.ai` | 供应商官网 | | ❸ API Key | 你的 OfoxAI API Key | 在 [app.ofox.ai](https://app.ofox.ai/manage/api-keys?utm=ofox_ai) 获取 | | ❹ 请求地址 | `https://api.ofox.ai/v1` | 末尾不要加斜杠 | | ❺ API 格式 | `OpenAI Compatible` | 选择 OpenAI 兼容格式 | | ❻ 写入通用配置 | ✅ 勾选 | 写入全局配置,所有项目生效 | CC Switch 自动写入配置文件,无需手动编辑任何文件。 ### 步骤三:启用供应商 添加完成后回到列表,选中 `ofoxai-codex`,点击**使用**按钮,看到「切换成功」提示即完成。确认 **写入通用配置** 已勾选,配置会自动写入 `config.toml`。 ![CC Switch 写入通用配置](https://ofox.ai/images/integrations/cc-switch-codex-step3.png) ## 3. 验证配置 ```bash codex "hello" ``` ![Codex CLI 运行效果](https://ofox.ai/screenshots/codex/03-run.png) 正常返回 AI 响应即表示配置成功。 ## 4. 指定模型 ```bash codex --model "重构这个函数" ``` Codex CLI 使用 **OpenAI Responses API**(`wire_api = "responses"`),并非所有模型都支持此格式。选择模型时,请在 [OfoxAI 模型广场](https://ofox.ai/zh/models) 确认该模型支持 **Responses** 协议,否则会报错。 推荐模型请参考 [OfoxAI 模型广场](https://ofox.ai/zh/models?utm=ofox_ai)。 ## 故障排除 **Q: 提示 "Authentication error"** 确认 API Key 已正确填写,并检查请求地址末尾无斜杠。 **Q: 连接超时** 确认请求地址为 `https://api.ofox.ai/v1`,末尾不带斜杠。