Codex 使用指南
本文介绍如何在 macOS 和 Windows 上安装 OpenAI Codex,并通过 Let AI Run 进行模型调用。
1. 准备 API Key
你需要先准备一个可用的 Let AI Run Key(示例以 sk- 开头),后续会写入 auth.json。
2. macOS 安装
- Codex APP
官网下载:https://chatgpt.com/codex
- Codex Cli
brew install codex
如果本机已有 Node.js,也可以使用 npm 全局安装:
npm install -g @openai/codex
3. macOS 通用配置
先创建隐藏目录(注意目录名包含前缀 .):
mkdir -p ~/.codex
在 ~/.codex/config.toml 写入:
model_provider = "letairun"
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
model_verbosity = "high"
[model_providers.letairun]
name = "letairun"
base_url = "https://api.letai.run/v1"
wire_api = "responses"
requires_openai_auth = true
[features]
fast_mode = false
prevent_idle_sleep = true
streamable_shell = false
同时创建 ~/.codex/auth.json:
{
"OPENAI_API_KEY": "your-api-key-here"
}
将 your-api-key-here 替换为你的真实 API Key。
4. Windows 安装
- Codex APP
官网下载:https://chatgpt.com/codex
- Codex Cli
- 安装 Node.js:
https://nodejs.org/zh-cn/download/current - 安装 Codex:
npm install -g @openai/codex
5. Windows 通用配置
创建目录(注意目录名包含前缀 .):
在文件管理器里面 %USERPROFILE% 就是你的用户名目录,然后创建.codex文件夹,如果有就直接打开 %USERPROFILE%\\.codex\\
%USERPROFILE%\\.codex\\
在 %USERPROFILE%\\.codex\\config.toml 写入:
model_provider = "letairun"
model = "gpt-5.5"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_verbosity = "high"
[model_providers.letairun]
name = "letairun"
base_url = "https://api.letai.run/v1"
wire_api = "responses"
requires_openai_auth = true
[features]
fast_mode = false
prevent_idle_sleep = true
streamable_shell = false
同时创建 %USERPROFILE%\\.codex\\auth.json:
{
"OPENAI_API_KEY": "your-api-key-here"
}
6. 启动方式
- 终端:运行
codex - VSCode / Cursor:安装 OpenAI 官方
Codex扩展后即可使用
7. 常见排查
- 输入
codex提示命令不存在:- 检查是否安装成功。
- 使用
npm安装时,确认全局安装目录已加入PATH。
- 提示认证失败:
- 检查
auth.json文件名和路径是否正确。 - 确认
OPENAI_API_KEY的值不是示例占位符。
- 检查
- 请求未走 Let AI Run:
- 检查
config.toml中base_url是否为https://api.letai.run/v1。
- 检查