orbstack 下 openclaw 搭配 cpa 配置流程

2026-04-29 08:483阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

自己在这个环境下搭建 OpenClaw 一直连不通 cpa ,来回调试终于成功了,用 AI 总结和润色了下教程,有类似的可以参考下

适用环境:

  • macOS
  • OrbStack
  • Ubuntu Machine 里运行 OpenClaw
  • OrbStack Docker 里运行 CLIProxyAPI
  • 使用 OpenAI 兼容接口

一、核心网络原理

当你:

  • OrbStack Machine(Ubuntu) 里运行 OpenClaw
  • macOS 的 OrbStack Docker 里运行 CLIProxyAPI

Machine 访问 Docker 转发端口时:

必须使用:

docker.orb.internal

不能用:

  • localhost
  • 127.0.0.1
  • 容器名
  • mac 本机 IP

二、端口统一使用 8317 (可自定义)

CLIProxyAPI 在 Docker 中暴露:

8317

因此在 Ubuntu Machine 里访问地址为:

http://docker.orb.internal:8317


三、在 Ubuntu Machine 中验证接口

进入 Machine:

orb -m ubuntu


测试 Chat 接口

curl http://docker.orb.internal:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-123" \ -d '{ "model":"gpt-5.3-codex", "messages":[{"role":"user","content":"ping"}], "stream": false }'

如果返回正常 JSON,说明:

  • 网络 OK
  • 端口 OK
  • CLIProxyAPI OK

四、OpenClaw 正确配置(关键)

配置文件路径:

~/.openclaw/agents/main/agent/models.json


正确写法(必须带 /v1)

{ "models": { "mode": "merge", "providers": { "cli-proxy": { "baseUrl": "http://docker.orb.internal:8317/v1", "apiKey": "sk-anything", "api": "openai-chat-completions", "models": [ { "id": "gpt-5.3-codex", "name": "gpt-5.3-codex", "api": "openai-chat-completions", "reasoning": false, "input": ["text"], "contextWindow": 200000, "maxTokens": 4096 } ] } } } }

修改完成后,重启 OpenClaw。


五、常见错误:HTTP 404 page not found

现象

OpenClaw 报:

HTTP 404: 404 page not found


原因(99% 是这个)

baseUrl 没带 /v1

错误写法:

"baseUrl": "http://docker.orb.internal:8317"

OpenClaw 会拼接:

/chat/completions

最终变成:

http://docker.orb.internal:8317/chat/completions

而 CLIProxyAPI 实际支持的是:

/v1/chat/completions

因此直接 404。


正确写法

"baseUrl": "http://docker.orb.internal:8317/v1"

这样最终请求路径是:

http://docker.orb.internal:8317/v1/chat/completions

即可正常工作。


六、排错方法(快速确认路径)

在 macOS 终端查看 CLIProxyAPI 日志:

docker logs -f <CLIProxyAPI容器名>

然后在 OpenClaw 发一句话。

如果日志显示:

POST /chat/completions

说明 baseUrl 少了 /v1。

如果显示:

POST /v1/chat/completions

说明路径正确。


总结

最关键三点:

Machine 访问 Docker 必须使用:

docker.orb.internal

端口统一使用:

8317

baseUrl 必须带:

/v1 网友解答:


--【壹】--:

大佬,我也是mac,跟你情况类似,然后docker里面安装了cpa、openclaw。现在openclaw访问不到cpa,我尝试过http://host.docker.internal:8317/v1,也是无法解析到


--【贰】--:

感谢分享!


--【叁】--:

感谢大佬!


--【肆】--:

感谢佬友分享


--【伍】--:

看下 model.json 有时候改了会不生效


--【陆】--: cookygg:

CLIProxyAPI

CLIProxyAPI 在 orbstack 里访问 codex 额度查询报超时,应该是代理配置问题,怎么在CLIProxyAPI镜像里面访问本机的clash 代理


--【柒】--:

我用的是 surge ,开了增强模式,虚拟机最终网络出口都会走这,我这是正常没问题的


--【捌】--: cookygg:

openai-chat-completions

试下 openai-completions


--【玖】--: cookygg:

openai-chat-completions

龙虾光说不做是怎么回事


--【拾】--:

现在都没有~/.openclaw/agents/main/agent/models.json这个配置文件了


--【拾壹】--:

感谢分享

标签:人工智能
问题描述:

自己在这个环境下搭建 OpenClaw 一直连不通 cpa ,来回调试终于成功了,用 AI 总结和润色了下教程,有类似的可以参考下

适用环境:

  • macOS
  • OrbStack
  • Ubuntu Machine 里运行 OpenClaw
  • OrbStack Docker 里运行 CLIProxyAPI
  • 使用 OpenAI 兼容接口

一、核心网络原理

当你:

  • OrbStack Machine(Ubuntu) 里运行 OpenClaw
  • macOS 的 OrbStack Docker 里运行 CLIProxyAPI

Machine 访问 Docker 转发端口时:

必须使用:

docker.orb.internal

不能用:

  • localhost
  • 127.0.0.1
  • 容器名
  • mac 本机 IP

二、端口统一使用 8317 (可自定义)

CLIProxyAPI 在 Docker 中暴露:

8317

因此在 Ubuntu Machine 里访问地址为:

http://docker.orb.internal:8317


三、在 Ubuntu Machine 中验证接口

进入 Machine:

orb -m ubuntu


测试 Chat 接口

curl http://docker.orb.internal:8317/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-123" \ -d '{ "model":"gpt-5.3-codex", "messages":[{"role":"user","content":"ping"}], "stream": false }'

如果返回正常 JSON,说明:

  • 网络 OK
  • 端口 OK
  • CLIProxyAPI OK

四、OpenClaw 正确配置(关键)

配置文件路径:

~/.openclaw/agents/main/agent/models.json


正确写法(必须带 /v1)

{ "models": { "mode": "merge", "providers": { "cli-proxy": { "baseUrl": "http://docker.orb.internal:8317/v1", "apiKey": "sk-anything", "api": "openai-chat-completions", "models": [ { "id": "gpt-5.3-codex", "name": "gpt-5.3-codex", "api": "openai-chat-completions", "reasoning": false, "input": ["text"], "contextWindow": 200000, "maxTokens": 4096 } ] } } } }

修改完成后,重启 OpenClaw。


五、常见错误:HTTP 404 page not found

现象

OpenClaw 报:

HTTP 404: 404 page not found


原因(99% 是这个)

baseUrl 没带 /v1

错误写法:

"baseUrl": "http://docker.orb.internal:8317"

OpenClaw 会拼接:

/chat/completions

最终变成:

http://docker.orb.internal:8317/chat/completions

而 CLIProxyAPI 实际支持的是:

/v1/chat/completions

因此直接 404。


正确写法

"baseUrl": "http://docker.orb.internal:8317/v1"

这样最终请求路径是:

http://docker.orb.internal:8317/v1/chat/completions

即可正常工作。


六、排错方法(快速确认路径)

在 macOS 终端查看 CLIProxyAPI 日志:

docker logs -f <CLIProxyAPI容器名>

然后在 OpenClaw 发一句话。

如果日志显示:

POST /chat/completions

说明 baseUrl 少了 /v1。

如果显示:

POST /v1/chat/completions

说明路径正确。


总结

最关键三点:

Machine 访问 Docker 必须使用:

docker.orb.internal

端口统一使用:

8317

baseUrl 必须带:

/v1 网友解答:


--【壹】--:

大佬,我也是mac,跟你情况类似,然后docker里面安装了cpa、openclaw。现在openclaw访问不到cpa,我尝试过http://host.docker.internal:8317/v1,也是无法解析到


--【贰】--:

感谢分享!


--【叁】--:

感谢大佬!


--【肆】--:

感谢佬友分享


--【伍】--:

看下 model.json 有时候改了会不生效


--【陆】--: cookygg:

CLIProxyAPI

CLIProxyAPI 在 orbstack 里访问 codex 额度查询报超时,应该是代理配置问题,怎么在CLIProxyAPI镜像里面访问本机的clash 代理


--【柒】--:

我用的是 surge ,开了增强模式,虚拟机最终网络出口都会走这,我这是正常没问题的


--【捌】--: cookygg:

openai-chat-completions

试下 openai-completions


--【玖】--: cookygg:

openai-chat-completions

龙虾光说不做是怎么回事


--【拾】--:

现在都没有~/.openclaw/agents/main/agent/models.json这个配置文件了


--【拾壹】--:

感谢分享

标签:人工智能