[GH-ISSUE #217] CC Switch 集成 AIClient2API 时,AIClient 供应商持续 401/UND_ERR_SOCKET,而 CCR 供应商正常 #157

Closed
opened 2026-02-27 07:18:16 +03:00 by kerem · 3 comments
Owner

Originally created by @Promisey on GitHub (Jan 12, 2026).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/217

在 CC Switch 中以 AIClient2API 作为网关时,两个供应商配置表现不一致:

  • CCR(CC Router → 下游指向 AIClient2API)工作正常,Claude Code 可以稳定对话。

  • AIClient(直接指向 AIClient2API)始终在“请求地址管理/测速”显示 401,Claude Code 端报 Unable to connect to API (UND_ERR_SOCKET)。

从 AIClient2API 实时日志看,AIClient/CCR 的实际对话 POST 请求均能到达并完成(使用次数持续增长、错误计数为 0),401 主要发生在客户端的 GET 探测阶段且未带认证头。

当请求地址改为完整的:http://localhost:8087/gemini-cli-oauth/v1/messages 时,报错404
运行环境

  • AIClient2API: v2.6.4.2

  • Node.js: v20.19.6

  • OS: Linux(容器/子进程模式)

  • 插件: default-auth(启用)、api-potluck(启用)

  • 代理: 网关侧“高级配置→代理地址”留空(不走代理)

  • Provider: gemini-cli-oauth(1/1 健康)

  • CC Switch: 启用本地代理(127.0.0.1:5000),日志开关开启

Image Image Image
Originally created by @Promisey on GitHub (Jan 12, 2026). Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/217 在 CC Switch 中以 AIClient2API 作为网关时,两个供应商配置表现不一致: - CCR(CC Router → 下游指向 AIClient2API)工作正常,Claude Code 可以稳定对话。 - AIClient(直接指向 AIClient2API)始终在“请求地址管理/测速”显示 401,Claude Code 端报 Unable to connect to API (UND_ERR_SOCKET)。 从 AIClient2API 实时日志看,AIClient/CCR 的实际对话 POST 请求均能到达并完成(使用次数持续增长、错误计数为 0),401 主要发生在客户端的 GET 探测阶段且未带认证头。 当请求地址改为完整的:http://localhost:8087/gemini-cli-oauth/v1/messages 时,报错404 运行环境 - AIClient2API: v2.6.4.2 - Node.js: v20.19.6 - OS: Linux(容器/子进程模式) - 插件: default-auth(启用)、api-potluck(启用) - 代理: 网关侧“高级配置→代理地址”留空(不走代理) - Provider: gemini-cli-oauth(1/1 健康) - CC Switch: 启用本地代理(127.0.0.1:5000),日志开关开启 <img width="2000" height="1678" alt="Image" src="https://github.com/user-attachments/assets/26eb1d21-bb1c-4e2e-91a3-3ffff2525180" /> <img width="1986" height="816" alt="Image" src="https://github.com/user-attachments/assets/09ea04fb-089a-4b3f-b50c-543860611d9e" /> <img width="1820" height="540" alt="Image" src="https://github.com/user-attachments/assets/1539a83e-43ac-40fc-8930-3fd858c05215" />
kerem closed this issue 2026-02-27 07:18:16 +03:00
Author
Owner

@justlovemaki commented on GitHub (Jan 12, 2026):

  1. 测速又不会传header,必然401
  2. aigocode的路径没有/v1及后面路径,aiclient为什么要加呢?
  3. 建议多了解了解计算机基本常识,及对应http错误码的原因
<!-- gh-comment-id:3737256619 --> @justlovemaki commented on GitHub (Jan 12, 2026): 1. 测速又不会传header,必然401 2. aigocode的路径没有/v1及后面路径,aiclient为什么要加呢? 3. 建议多了解了解计算机基本常识,及对应http错误码的原因
Author
Owner

@Promisey commented on GitHub (Jan 12, 2026):

主要的问题是Claude Code 端报 Unable to connect to API (UND_ERR_SOCKET)。

所以才去排查测速、尝试加/v1/messages,但都没有解决,然后看CC Switch里面用CCR的配置测速时是200的状态

Image

在 CCR 和 Cheery Studio 里面配置 AIClient2API 作为供应商,都已经是能正常使用的(Cheery Studio 里面关流式输出才行)

感谢作者回复,麻烦了🙏
的确不是程序员,后面我再多学习、尝试

<!-- gh-comment-id:3737417866 --> @Promisey commented on GitHub (Jan 12, 2026): 主要的问题是Claude Code 端报 Unable to connect to API (UND_ERR_SOCKET)。 所以才去排查测速、尝试加/v1/messages,但都没有解决,然后看CC Switch里面用CCR的配置测速时是200的状态 <img width="2000" height="1302" alt="Image" src="https://github.com/user-attachments/assets/709f0d40-7178-49a0-9063-616d2e714f0b" /> 在 CCR 和 Cheery Studio 里面配置 AIClient2API 作为供应商,都已经是能正常使用的(Cheery Studio 里面关流式输出才行) 感谢作者回复,麻烦了🙏 的确不是程序员,后面我再多学习、尝试
Author
Owner

@Promisey commented on GitHub (Jan 12, 2026):

找到原因了,大概是快被限流了,参照这个帖子

https://github.com/lbjlaq/Antigravity-Manager/issues/284

在CC Switch中,相同的配置,换模型就能在Claude Code里正常对话了;还有关闭CC Switch中的Proxy开关,如果使用Clash之类的代理的话。

<!-- gh-comment-id:3739010355 --> @Promisey commented on GitHub (Jan 12, 2026): 找到原因了,大概是快被限流了,参照这个帖子 https://github.com/lbjlaq/Antigravity-Manager/issues/284 在CC Switch中,相同的配置,换模型就能在Claude Code里正常对话了;还有关闭CC Switch中的Proxy开关,如果使用Clash之类的代理的话。
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#157
No description provided.