智能助手网
标签聚合 codex

/tag/codex

linux.do · 2026-04-18 22:47:42+08:00 · tech

CPA + Codex 配置避坑指南 前言 本文记录了配置 CLI Proxy API (CPA) 与 Codex 集成时遇到的各种坑,希望能帮助后来者少走弯路。 环境信息 系统 : macOS (Apple Silicon) CPA 版本 : v6.9.29 Codex 版本 : 0.121.0 代理工具 : ClashX / Clash Verge 核心问题:502 Bad Gateway 症状 Codex 启动后尝试连接 API 时,反复出现: Unexpected status 502 Bad Gateway: Unknown error, url: http://localhost:8321/v1/responses 根本原因 系统代理拦截了 localhost 请求! ClashX/Clash Verge 等代理工具默认会拦截所有 HTTP 请求,包括 localhost 和 127.0.0.1 。当 Codex 尝试访问本地 CPA 服务时,请求被代理转发,导致: 请求无法直接到达本地服务 代理返回 502 错误 日志中看不到任何请求记录(因为请求根本没到达目标服务) 解决方案 方法 1:设置 NO_PROXY 环境变量(推荐) # 添加到 ~/.zshrc 或 ~/.bashrc export NO_PROXY="localhost,127.0.0.1" # 应用配置 source ~/.zshrc 重要: 必须在新终端中启动 Codex,才能加载新的环境变量。 方法 2:配置代理绕过规则 在 ClashX/Clash Verge 中添加绕过规则,让 localhost 不走代理。 其他常见问题 1. API Key 不匹配 (401 Unauthorized) 症状: Unexpected status 401 Unauthorized: {"error":"Invalid API key"} 原因: Codex 使用了自己的 API key(格式如 sk-sub-Pack6n6X... ),而不是配置文件中的 api_key 。 解决方案: 将 Codex 使用的 key 添加到 CPA 配置中: # ~/cpa-config.yaml api-keys: - "your-custom-key" - "sk-sub-Pack6n6X_yKXdwEwPB2mT0iGkcQyE4IMMHe-kCN7TIy4L-gf" # Codex 的 key 重启 CPA: pkill -f "cpa.*config" ~/.local/bin/cpa -config ~/cpa-config.yaml > /tmp/cpa.log 2>&1 & 2. 端口被占用 症状: Error: listen EADDRINUSE: address already in use 127.0.0.1:8321 原因: 旧的 shim 进程还在运行 LaunchAgent 自动重启服务 解决方案: # 查找占用端口的进程 lsof -nP -iTCP:8321 -sTCP:LISTEN # 停止进程 kill -9 <PID> # 禁用自动启动 launchctl unload ~/Library/LaunchAgents/com.linkunkun.codex.cliproxy-shim.plist 3. 旧版本冲突 症状: Homebrew 安装的旧版本 cliproxyapi 自动重启。 解决方案: # 停止 Homebrew 服务 brew services stop cliproxyapi # 卸载旧版本 brew uninstall cliproxyapi # 清理配置 rm -rf /opt/homebrew/etc/cliproxyapi* rm -f ~/Library/LaunchAgents/homebrew.mxcl.cliproxyapi.plist 4. Shim 是否必需? 答案:不需要! 早期以为需要 shim 来转换请求格式,但实际上: CPA 原生支持 /v1/responses 端点 直接连接 CPA 更简洁高效 推荐配置: # ~/.codex/config.toml [model_providers.custom] name = "custom" wire_api = "responses" base_url = "http://localhost:8317/v1" # 直接连 CPA api_key = "your-api-key" 完整安装步骤 1. 安装 CPA # 下载最新版本 curl -L -o /tmp/cpa.tar.gz https://github.com/router-for-me/CLIProxyAPI/releases/download/v6.9.29/CLIProxyAPI_6.9.29_darwin_arm64.tar.gz # 解压并安装 cd /tmp tar -xzf cpa.tar.gz mkdir -p ~/.local/bin mv cli-proxy-api ~/.local/bin/cpa chmod +x ~/.local/bin/cpa # 添加到 PATH echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc source ~/.zshrc 2. 配置 CPA # 复制示例配置 cp /tmp/config.example.yaml ~/cpa-config.yaml # 编辑配置 vim ~/cpa-config.yaml 关键配置项: port: 8317 # 管理密钥 remote-management: secret-key: "your-admin-password" # API keys api-keys: - "your-api-key" 3. 启动 CPA nohup ~/.local/bin/cpa -config ~/cpa-config.yaml > /tmp/cpa.log 2>&1 & 4. 配置 Codex # ~/.codex/config.toml model_provider = "custom" model = "gpt-5.4" [model_providers.custom] name = "custom" wire_api = "responses" base_url = "http://localhost:8317/v1" api_key = "your-api-key" 5. 配置代理绕过(关键!) # 添加到 ~/.zshrc echo 'export NO_PROXY="localhost,127.0.0.1"' >> ~/.zshrc source ~/.zshrc 6. 测试 # 测试 CPA curl http://localhost:8317/v1/models -H "Authorization: Bearer your-api-key" # 在新终端启动 Codex codex 调试技巧 1. 查看 CPA 日志 tail -f /tmp/cpa.log 2. 查看 Codex 日志 tail -f ~/.codex/log/codex-tui.log 3. 检查端口占用 lsof -nP -iTCP:8317 -sTCP:LISTEN 4. 测试 API 连接 curl -v http://localhost:8317/v1/responses \ -H "Authorization: Bearer your-api-key" \ -H "Content-Type: application/json" \ -d '{"model":"gpt-5.4","input":[{"role":"user","content":[{"type":"input_text","text":"test"}]}]}' 5. 检查代理设置 # 查看环境变量 env | grep -i proxy # 查看活动连接 lsof -nP -iTCP | grep codex | grep ESTABLISHED 常见错误排查流程 502 Bad Gateway ↓ 检查是否有代理 (lsof -nP -iTCP | grep codex) ↓ 有代理 → 设置 NO_PROXY ↓ 无代理 → 检查服务是否运行 ↓ 401 Unauthorized ↓ 检查 Codex 使用的 API key (查看日志) ↓ 将 key 添加到 CPA 配置 ↓ 重启 CPA 总结 配置 CPA + Codex 的最大坑就是 系统代理 。记住: 设置 NO_PROXY 环境变量 在新终端启动 Codex 直接连接 CPA,不需要 shim 将 Codex 的 API key 添加到 CPA 配置 遵循这些原则,可以避免 90% 的问题。 参考资源 CPA GitHub CPA 文档 管理界面 最后更新 : 2026-04-18 作者 : 基于实际踩坑经历整理 5 个帖子 - 3 位参与者 阅读完整话题

linux.do · 2026-04-18 22:06:10+08:00 · tech

我个人观察到的现象是,会话创建后的首条消息正常,之后的消息会延迟数秒才能发出,在 mac 和 windows 平台都出现了此问题; 并且 mac 版本还出现了运行时 cpu 使用率过高,发热严重的问题。 github 上也有不少类似的反馈,首个发现的版本应该是 26.415.21839 ;有人反映关闭记忆功能后可绕过此问题,但对大多数人包括我自己无效,目前只能通过降级解决。 github.com/openai/codex Fix: Desktop App - Message send is delayed for ~8 seconds in new sessions after the latest update 已打开 04:31AM - 17 Apr 26 UTC JavierPiedra bug app session ### What version of the Codex App are you using (From “About Codex” dialog)? 26 … .415.21839 ### What subscription do you have? Pro ### What platform is your computer? Darwin 25.3.0 arm64 arm ### What issue are you seeing? ## Summary In the Codex desktop app, sending a message can take around 8 seconds before the message is actually sent. This appears to have started after the latest update. It did not happen in older sessions before. ## Environment - App: Codex desktop app - Codex version: `26.415.21839 (1763)` - macOS: `26.3.1 (build 25D771280a)` - Hardware: `MacBook Air (Apple M3, 24 GB RAM)` ## Actual behavior After pressing Enter to send a message, the message does not send immediately. Observed behavior: - The spinner appears in the send button - The message remains pending for about `8 seconds` - Lowering reasoning does not help This is affecting sessions created after the latest update. ### What steps can reproduce the bug? ## Reproduction Observed repro: 1. Open Codex desktop 2. Open a newer thread created after the latest update 3. Type a normal message 4. Press Enter 5. Observe the spinner in the send button and a delay of about `8 seconds` before the message is sent Additional observation: - In a brand-new thread, the first message sent immediately - The second message in that same new thread then started taking a very long time to send ## Scope / pattern - Happens in newer sessions created after the latest update - Did **not** happen in older sessions tested by the user - Not fixed by lowering reasoning - Seen with `GPT-5.4` and `Extra High`, but reasoning level does not appear to be the cause ### What is the expected behavior? ## Expected behavior Pressing Enter should enqueue and send the message immediately, or at least show near-instant client acknowledgment. ### Additional information ## Notes This feels like client-side send latency rather than raw network latency. Local diagnostics from the machine at the time: - Network path looked healthy in macOS logs - Codex renderer/helper processes showed noticeable CPU activity while the issue was occurring - No obvious network failure was visible from the local system logs ## Impact This makes normal back-and-forth use of Codex frustrating because even short messages feel blocked before they are sent. If you want, I can also compress this into a shorter GitHub-style version, or turn it into a more technical issue with a small `Additional diagnostics` section at the end. 本以为是梯子又出问题,但看了下发现是 app 的锅,记录一下 9 个帖子 - 8 位参与者 阅读完整话题

linux.do · 2026-04-18 21:18:36+08:00 · tech

前天开gpt5.4pro的进阶思考,每次大约要7-10分钟,昨天6分钟左右,今天4-5分钟。codex上使用也是一样,前几天死慢,但是思考确实很有深度,并且检查的异常细致,把可能出现的风险点都加上了,最令我惊讶的他还能通过网络找对标案例来进行分析。今天思考异常短,并且经常做一些低级的错误。现在AI是个循环了,新模型——买——降智——换——新模型。我这几天也在思考,之前开个影音会员又是拼车又是尼区,现在买个token真舍得花钱,一个max说买就买,一个pro说买就买 2 个帖子 - 2 位参与者 阅读完整话题

linux.do · 2026-04-18 21:02:53+08:00 · tech

抽奖主题:抽10个codex free json 账号,导入就可以使用 奖品详情: [奖品1]:[5个codex] [奖品2]:[5个codex] 活动时间: 开始时间: Sat, Apr 18, 2026 9:00 PM CST 截止时间: Sun, Apr 19, 2026 9:00 PM CST 参与方式: 在本贴下回复任意内容即可参与。 抽奖规则: 每位用户仅允许参与一次。 将使用 LINUX DO 抽奖工具 在所有回复中随机抽取中奖者。 注意事项: 本活动将在活动截止时间后关闭回帖,以确保公正性。 中奖者将在活动结束后在本帖公布,并通过论坛站内信由发起人通知领奖方式。 所有规则及抽奖结果由 @kexincolar 及论坛 管理团队 最终解释。 发起人承诺: 作为本次抽奖的发起人 @kexincolar ,我承诺本话题的抽奖活动严格遵守 LINUX DO 社区抽奖规则 。因违反上述规定引发的公平性争议或其他问题,均由我独立承担相应的道德与法律责任。 期待您的积极参与,祝您好运!如有任何疑问,欢迎随时联系 @kexincolar 或论坛 管理团队 。 44 个帖子 - 44 位参与者 阅读完整话题

linux.do · 2026-04-18 20:36:15+08:00 · tech

我的问题:我无法在我的vps上用我的claudecode与codex 昨天我的claude与codex都能用,今天又崩了 我尝试把本地的能用的关键配置文件上传到里面,还是失败不能动,我怀疑是网络问题 vps是无界面的linux 我目前有2个GPT 一个team一个plus(官方) 两个中转站 any与jobema (分别调用claude与glm5.1模型) 我的科学工具 1.clash for linux 2.shellcrash 我能不能ping通youtube? export http_proxy="127.0.0.1:7890" 后,依旧不能,但是之前不能,可是codex还是能动 我的尝试方法 1.npx zcf 2.ccr 3.cc-switch 我想要什么? 我想要有个通用万能简单上手的,直接配置ai的 baseurl key model 就能用的,cli下的一个工具 opencode? 目前打算:卸载目前npx zcf,重新安装,重新配置 1 个帖子 - 1 位参与者 阅读完整话题