Codex CLI 是一款命令行 AI 编程助手,支持在终端中进行代码生成和问答。
安装
- Windows
- macOS
- Linux
步骤 1:安装 NVM(Node 版本管理器)
打开 PowerShell(管理员模式),下载并安装 nvm-windows:
# 下载 nvm-windows 安装包
# 访问 https://github.com/coreybutler/nvm-windows/releases
# 下载最新的 nvm-setup.exe 并运行安装
或使用 Chocolatey 安装:
choco install nvm
步骤 2:安装 Node.js
# 安装最新 LTS 版本
nvm install lts
# 使用该版本
nvm use lts
# 验证安装
node --version
npm --version
步骤 3:安装 Codex CLI
npm install -g @openai/codex@latest
步骤 4:验证安装
codex --version
配置 weelinking
- Windows
- macOS
- Linux
步骤 1:创建配置目录
# 创建配置目录
New-Item -Path "$env:USERPROFILE.codex" -ItemType Directory -Force
步骤 2:创建 config.toml 文件
在 %USERPROFILE%.codex 目录下创建 config.toml 文件:
@"
model_provider = "weelinking"
model = "gpt-5.2-codex"
model_reasoning_effort = "xhigh"
network_access = "enabled"
disable_response_storage = true
[model_providers.weelinking]
name = "weelinking"
base_url = "https://api.weelinking.com/v1"
wire_api = "responses"
requires_openai_auth = true
"@ | Out-File -FilePath "$env:USERPROFILE.codex\config.toml" -Encoding UTF8
步骤 3:创建 auth.json 文件
在同一目录下创建 auth.json 文件:
@"
{
"OPENAI_API_KEY": "您的 CodeX 专用分组令牌 key"
}
"@ | Out-File -FilePath "$env:USERPROFILE.codex\auth.json" -Encoding UTF8
使用方法
交互模式
codex
直接执行
codex "写一个 Python 快速排序算法"
管道输入
- Windows
- macOS
- Linux
Get-Content code.py | codex "解释这段代码"
功能特色
- 代码生成:根据描述生成代码
- 代码解释:解释代码逻辑
- 命令行集成:与 shell 无缝协作
- 多语言支持:支持各种编程语言
推荐模型
| 场景 | 模型 |
|---|---|
| 代码生成 | gpt-5.2-codex |
| 快速问答 | gpt-4o-mini |
| 复杂任务 | claude-sonnet-4-5 |
实测推荐:国内可用的claude平台,也支持GPT-5/Gemini等模型,新用户有100元额度,大家快来薅羊毛→ api.weelinking.com/register?af…
安装文档:docs.weelinking.com/docs/scenar… 通过使用我们的中转API,以及附带的安装配置流程,可以轻松完美使用codex-cli!