
`brew install cliproxyapi` 找不到 formula 时,不必继续在 Homebrew 上耗时间。直接使用 GitHub Release 的 macOS Apple Silicon 二进制包,再用 `launchd`
brew install cliproxyapi 找不到 formula 时,不必继续在 Homebrew 上耗时间。直接使用 GitHub Release 的 macOS Apple Silicon 二进制包,再用 launchd 持久化运行,是这篇指南的最小可用路径。
本文记录在 macOS arm64 上安装 CLIProxyAPI_6.8.49_darwin_arm64、配置本地代理、完成上游账号登录,并通过 launchd 开机自启。最终本地服务监听 http://127.0.0.1:8317/v1,客户端使用本地 API Key sk-local-test-123 访问。
这篇适合:
sudo 安装二进制的人nohup 临时挂着的人本文基于以下环境:
arm64/Users/rodydustCLIProxyAPI_6.8.49_darwin_arm64项目地址:
安装时执行:
brew install cliproxyapi
会得到:
Warning: No available formula with the name "cliproxyapi".
所以这里改走 GitHub Release 二进制安装。这个选择的好处是路径明确、版本明确,也方便在 launchd 的 plist 中写死可执行文件路径。
假设 Release 包已经解压到:
/Users/rodydust/Downloads/CLIProxyAPI_6.8.49_darwin_arm64
目录中的主要文件包括:
cli-proxy-apiconfig.example.yamlREADME.mdREADME_CN.md为了避免使用 sudo,把二进制安装到用户目录:
mkdir -p ~/.local/bin
install -m 755 ~/Downloads/CLIProxyAPI_6.8.49_darwin_arm64/cli-proxy-api ~/.local/bin/cli-proxy-api
把用户目录加入 PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
验证安装:
which cli-proxy-api
期望输出类似:
/Users/rodydust/.local/bin/cli-proxy-api
先创建配置目录:
mkdir -p ~/.cli-proxy-api
创建配置文件 ~/.cli-proxy-api/config.yaml:
host: "127.0.0.1"
port: 8317
auth-dir: "~/.cli-proxy-api"
api-keys:
- "sk-local-test-123"
debug: false
logging-to-file: false
几个字段不要理解错:
host: "127.0.0.1" 表示只监听本机,更适合个人本地使用。port: 8317 是本地代理端口。auth-dir 保存认证信息。api-keys 是客户端访问本地代理的 Key,不是上游模型厂商的 Key。如果只在本机使用,不建议把 host 改成 0.0.0.0。那会把服务暴露到本机以外的网络环境,风险和排查成本都会上升。
根据要接入的上游平台,执行对应命令。
Codex / OpenAI:
cli-proxy-api --codex-login
Claude:
cli-proxy-api --claude-login
Gemini:
cli-proxy-api --login
登录完成后,认证信息会保存到:
~/.cli-proxy-api
在配置 launchd 前,先前台启动服务,确认二进制、配置和登录信息都能工作:
cli-proxy-api --config ~/.cli-proxy-api/config.yaml
本地访问地址:
http://127.0.0.1:8317/v1
本地 API Key:
sk-local-test-123
launchd 比 nohup 更适合长期运行,因为它可以:
创建日志目录:
mkdir -p ~/.cli-proxy-api/logs
创建 LaunchAgent 文件:
~/Library/LaunchAgents/me.rodydust.cli-proxy-api.plist
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>me.rodydust.cli-proxy-api</string>
<key>ProgramArguments</key>
<array>
<string>/Users/rodydust/.local/bin/cli-proxy-api</string>
<string>--config</string>
<string>/Users/rodydust/.cli-proxy-api/config.yaml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>/Users/rodydust</string>
<key>StandardOutPath</key>
<string>/Users/rodydust/.cli-proxy-api/logs/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/rodydust/.cli-proxy-api/logs/stderr.log</string>
</dict>
</plist>
加载并启动服务:
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/me.rodydust.cli-proxy-api.plist
launchctl kickstart -k gui/$(id -u)/me.rodydust.cli-proxy-api
查看服务状态:
launchctl print gui/$(id -u)/me.rodydust.cli-proxy-api
查看日志:
tail -f ~/.cli-proxy-api/logs/stdout.log
tail -f ~/.cli-proxy-api/logs/stderr.log
停止服务:
launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/me.rodydust.cli-proxy-api.plist
重启服务:
launchctl kickstart -k gui/$(id -u)/me.rodydust.cli-proxy-api
源文记录的本机状态是:
/Users/rodydust/.local/bin/cli-proxy-api/Users/rodydust/.cli-proxy-api/config.yamllaunchd 配置写入:/Users/rodydust/Library/LaunchAgents/me.rodydust.cli-proxy-api.plist8317日志中确认:
CLIProxyAPI Version: 6.8.49
API server started successfully on: :8317
检查端口监听:
lsof -nP -iTCP:8317 -sTCP:LISTEN
检查启动日志:
tail -n 50 ~/.cli-proxy-api/logs/stdout.log
检查错误日志:
tail -n 50 ~/.cli-proxy-api/logs/stderr.log
检查命令路径:
which cli-proxy-api
其他本地客户端要连接这个代理时,使用:
http://127.0.0.1:8317/v1sk-local-test-123后续接入 Codex CLI、Claude Code 或 Gemini CLI 时,把它们的 base_url 指向这个本地代理地址即可。
这套方案适合本机代理,不适合默认暴露给局域网或公网。它依赖本地认证目录,如果换账号或重新登录,上游认证信息一般仍保存在 ~/.cli-proxy-api。
如果要多人共用,先重新设计认证、访问控制和日志策略,不要直接把这份本地配置改成共享服务。
Anthropic以1.5万亿美元估值完成史上最大IPO,创始人套现近20亿美元;AWS发布由智能体编写的本地模拟器并扩展智能体支付治理,BMW分享规模化治理实践,llama.cpp持续优化本地推理,OpenSSL曝高危漏洞。
今日AI领域迎来Gemini 4正式发布,OpenAI与Vercel等开发工具链密集更新,llama.cpp持续优化推理性能。Anthropic因代码合并量激增自研源码控制,脑机接口与家庭AI助手加速落地,Cerebras CEO则批评AI末日论。
今日AI领域无重大模型发布,但推理优化与开发工具链更新密集:llama.cpp修复Hexagon DMA溢出并优化SYCL量化推理,OpenAI Node SDK新增预热托管环境,Vercel AI SDK修复流式超时,ttok 1.0切换默认分词器。
新内容发布后发送确认邮件,不会把未验证或已退订地址加入发送列表。
欢迎理性讨论与补充勘误
无需登录即可评论,展示名称会使用脱敏 IP。
暂无评论