Codex 配置
Codex 是 OpenAI 官方的命令行编码工具。本页介绍接入 API 码头的配置流程。
全局安装 Codex CLI:
npm install -g @openai/codexmacOS 配置
Section titled “macOS 配置”1. 打开配置目录
Section titled “1. 打开配置目录”配置目录在 ~/.codex,不存在则新建:
mkdir -p ~/.codex2. 创建 config.toml
Section titled “2. 创建 config.toml”在 ~/.codex/config.toml 写入以下内容:
model_provider = "apimatou"model = "gpt-5.5"model_reasoning_effort = "high"disable_response_storage = true
[model_providers.apimatou]name = "apimatou"base_url = "https://apimatou.cc"wire_api = "responses"requires_openai_auth = truebase_url 是 API 码头中转地址,不要在末尾加 /v1;wire_api 固定为 responses。
3. 创建 auth.json
Section titled “3. 创建 auth.json”在 ~/.codex/auth.json 写入(替换为控制台的真实 Key):
{ "OPENAI_API_KEY": "你的API_KEY"}4. 验证配置
Section titled “4. 验证配置”在任意项目目录运行:
codex进入交互界面后随便问一个问题。模型正常返回即接入成功;若报 401 / 403,请检查 auth.json 的 Key 与 config.toml 的 base_url。
Windows 配置
Section titled “Windows 配置”1. 打开配置目录
Section titled “1. 打开配置目录”配置目录在 %USERPROFILE%\.codex,不存在则新建:
mkdir %USERPROFILE%\.codex2. 创建 config.toml
Section titled “2. 创建 config.toml”在 %USERPROFILE%\.codex\config.toml 写入以下内容:
model_provider = "apimatou"model = "gpt-5.5"model_reasoning_effort = "high"disable_response_storage = true
[model_providers.apimatou]name = "apimatou"base_url = "https://apimatou.cc"wire_api = "responses"requires_openai_auth = truebase_url 是 API 码头中转地址,不要在末尾加 /v1;wire_api 固定为 responses。
3. 创建 auth.json
Section titled “3. 创建 auth.json”在 %USERPROFILE%\.codex\auth.json 写入(替换为控制台的真实 Key):
{ "OPENAI_API_KEY": "你的API_KEY"}4. 验证配置
Section titled “4. 验证配置”在任意项目目录运行:
codex进入交互界面后随便问一个问题。模型正常返回即接入成功;若报 401 / 403,请检查 auth.json 的 Key 与 config.toml 的 base_url。
- 报
model not supported:确认model字段写的是gpt-5.5,注意点号与小写。 - 报 401 / invalid_api_key:检查
auth.json的 Key 是否完整、是否在控制台已启用。 - 请求超时:检查
base_url是否为https://apimatou.cc(不要带/v1),网络是否通畅。