客户端接入
Codex 配置教程
通过一键脚本或手动配置接入 ZhenAPI,完成 Codex CLI 与桌面端的模型、API Key 和 Responses 接口设置。
安装并配置 Codex,通过 ~/.codex 连接 ZhenAPI 平台。
按系统选择一键脚本
脚本会自动检测 Node.js 和 Codex CLI,缺失时引导安装;随后提示输入 API Key,并写入 ~/.codex 配置。复制命令不包含密钥。
POWERSHELL
1irm https://zhenapi.ai/install/codex.ps1 | iex运行命令后,等 PowerShell 提示输入 API Key,再用鼠标右键粘贴完整密钥,然后按回车。不要用 Ctrl+V 等粘贴快捷键。
BASH
1curl -fsSL https://zhenapi.ai/install/codex.sh | bash 💡 配置写入
~/.codex 后,Codex CLI 和 Codex App 客户端会同时生效;配置写入后,已打开的 CLI 需要重启后才会读取新配置。 ⚠️ 注意:手动安装前请先完成 Node.js 环境安装教程。
第一步:安装 Codex
CMD / PowerShell
1npm install -g @openai/codex@latest以上命令会从 npm 官方仓库下载并安装最新版本的 Codex 工具。
验证安装
TERMINAL
1codex --version如果显示版本号,恭喜你!Codex 已经成功安装了。
第二步:创建配置文件
Codex 只需配置 config.toml,将 API 密钥填写到 experimental_bearer_token。
POWERSHELL
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# 创建 config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)BASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFBASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF 💡 提示:请将命令中的
YOUR_API_KEY 替换为在 控制台 页面中复制的任意 API Key。 BASH
1sudo npm install -g @openai/codex@latest以上命令会从 npm 官方仓库下载并安装最新版本的 Codex 工具。
验证安装
TERMINAL
1codex --version如果显示版本号,恭喜你!Codex 已经成功安装了。
第二步:创建配置文件
Codex 只需配置 config.toml,将 API 密钥填写到 experimental_bearer_token。
POWERSHELL
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# 创建 config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)BASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFBASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF 💡 提示:请将命令中的
YOUR_API_KEY 替换为在 控制台 页面中复制的任意 API Key。 BASH
1npm install -g @openai/codex@latest以上命令会从 npm 官方仓库下载并安装最新版本的 Codex 工具。
验证安装
TERMINAL
1codex --version如果显示版本号,恭喜你!Codex 已经成功安装了。
第二步:创建配置文件
Codex 只需配置 config.toml,将 API 密钥填写到 experimental_bearer_token。
POWERSHELL
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.codex" | Out-Null3$utf8NoBom = New-Object System.Text.UTF8Encoding($false)4 5# 创建 config.toml6$config = @'7model_provider = "codex"8model = "gpt-6.1-sol"9model_reasoning_effort = "high"10model_context_window = 27200011sandbox_mode = "workspace-write"12 13[model_providers.codex]14name = "codex"15base_url = "https://api.zhenapi.ai/v1"16wire_api = "responses"17requires_openai_auth = false18supports_websockets = false19experimental_bearer_token = "YOUR_API_KEY"20http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }21 22[desktop]23conversationDetailMode = "STEPS_COMMANDS"24 25[sandbox_workspace_write]26network_access = true27 28[features]29goals = true30'@31[System.IO.File]::WriteAllText("$env:USERPROFILE\.codex\config.toml", $config, $utf8NoBom)BASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOFBASH
1# 创建配置目录(已有配置会被下面的命令覆盖,建议先自行备份)2mkdir -p ~/.codex3 4# 创建 config.toml5cat > ~/.codex/config.toml << 'EOF'6model_provider = "codex"7model = "gpt-6.1-sol"8model_reasoning_effort = "high"9model_context_window = 27200010sandbox_mode = "workspace-write"11 12[model_providers.codex]13name = "codex"14base_url = "https://api.zhenapi.ai/v1"15wire_api = "responses"16requires_openai_auth = false17supports_websockets = false18experimental_bearer_token = "YOUR_API_KEY"19http_headers = { "x-openai-actor-authorization" = "zhenapi.ai" }20 21[desktop]22conversationDetailMode = "STEPS_COMMANDS"23 24[sandbox_workspace_write]25network_access = true26 27[features]28goals = true29EOF 💡 提示:请将命令中的
YOUR_API_KEY 替换为在 控制台 页面中复制的任意 API Key。