本指南面向 Windows 用户,使用 放心API 作为 API 服务商,完成 Codex CLI 的完整安装与配置。
npm install -g @openai/codexcodex -VRemove-Item -Recurse -Force "$env:USERPROFILE\.codex" -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path "$env:USERPROFILE\.codex"auth.json,填入步骤 2 中复制的 API Key。你的API_KEY 替换为实际密钥):@'
{
"OPENAI_API_KEY": "你的API_KEY"
}
'@ | Set-Content "$env:USERPROFILE\.codex\auth.json" -Encoding UTF8{
"OPENAI_API_KEY": "你的API_KEY"
}C:\Users\你的用户名\.codex\auth.json,编码选择 UTF-8@'
model_provider = "fangxin"
model = "gpt-5.4"
model_reasoning_effort = "xhigh"
disable_response_storage = true
preferred_auth_method = "apikey"
[model_providers.fangxin]
name = "fangxin"
base_url = "https://fangxinapi.com/v1"
wire_api = "responses"
'@ | Set-Content "$env:USERPROFILE\.codex\config.toml" -Encoding UTF8C:\Users\你的用户名\.codex\config.toml,编码选择 UTF-8。codex -Vcd C:\Users\你的用户名\Desktop
codex# 进入你的项目目录
cd C:\path\to\your-project
# 启动 Codex
codexcodex # 启动交互模式
codex -V # 查看版本
codex --help # 查看帮助PATH 中,或安装后未刷新环境变量。C:\Users\你的用户名\.codex\auth.json,确认 OPENAI_API_KEY 已替换为实际密钥C:\Users\你的用户名\.codex\config.toml,确认 base_url 为 https://fangxinapi.com/v1wire_api = "responses" 未被修改Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserY 确认,然后重新运行安装命令。