Skip to content

Claude Desktop 支持通过 Gateway 模式接入第三方推理后端。将 Gateway Base URL 设为 https://openrouter.ai/api,填入 OpenRouter API key 并选择 bearer 认证方案,即可将 Claude Desktop 路由到 OpenRouter。接入后可获得 Provider 故障自动转移、团队积分预算管控、全员用量可视化等能力。无需 Anthropic 账号,使用 OpenRouter 积分计费。

通过 OpenRouter 使用 Claude Desktop,可以在 Anthropic API 与 Claude Desktop 之间加入可靠性和管理层,获得 Provider 自动故障转移、团队预算管控等能力。

为什么通过 OpenRouter 使用 Claude Desktop?

Provider 故障自动转移

Anthropic API 偶发限流或中断时,通过 OpenRouter 的请求会自动切换到其他 Provider,保持会话不中断。

团队预算管控

集中管理团队预算:设置用量上限、分配积分给各成员、防止意外超支。

用量可视化

OpenRouter 活动面板中追踪全团队的 Claude Desktop 用量模式和成本。

前置要求

配置步骤

第一步:启用开发者模式

打开 Claude Desktop,无需登录。打开 Help > Troubleshooting,点击 Enable Developer Mode,菜单栏将出现 Developer 菜单。

第二步:打开第三方推理面板

点击菜单栏 Developer > Configure Third-Party Inference…

第三步:填写 Gateway 凭证

将后端设为 Gateway (Anthropic-compatible),填写以下信息:

字段
Gateway Base URLhttps://openrouter.ai/api
Gateway API Key你的 OpenRouter API key(sk-or-v1-...
Gateway Auth Schemebearer

点击 Apply locally 保存配置。

第四步:重启并启动

完全退出 Claude Desktop(不是只关闭窗口),重新打开。启动界面选择 Continue with Gateway(显示为 "Local configuration")。无需 Anthropic 账号。

第五步:选择模型

模型选择器将显示通过 OpenRouter 连接可用的模型列表。

工作原理

  1. Gateway 模式:将 Claude Desktop 配置为使用 Gateway 后端(https://openrouter.ai/api),应用直接用原生 Anthropic 协议与 OpenRouter 通信,无需本地代理
  2. Anthropic 协议层:OpenRouter 的 "Anthropic Skin" 完全兼容 Anthropic Messages API,支持思考块和原生工具调用
  3. 计费:通过 OpenRouter 积分计费,用量显示在 OpenRouter 面板中

Claude Code

Claude Code 是 Anthropic 独立的 CLI 编程 agent,也支持通过 OpenRouter 使用。若偏好终端工作流,参见 Claude Code 集成指南,了解环境变量配置、模型设置、Fast Mode 和 GitHub Action 集成详情。

故障排除

  • 连接错误:确认 Gateway Base URL 正好是 https://openrouter.ai/api(无需 /v1),API key 有效,认证方案为 bearer
  • 无模型显示:确认 OpenRouter 账号有积分余额,访问 openrouter.ai/credits 检查
  • "Continue with Gateway" 未显示:确认已点击 Apply locally 并完全退出重启了 Claude Desktop(不是只关闭窗口)
  • WebFetch 工具被 Cowork 网络拦截:Cowork 沙箱默认限制 WebFetch 的网络访问。在 Developer > Configure Third-Party Inference… > Sandbox & workspace 标签页中,将所需主机添加到 Allowed egress hosts
  • 隐私:OpenRouter 不记录 prompt 内容,除非你在账号设置中主动开启 prompt 日志

常见问题

Q: 通过 OpenRouter 的 Claude Desktop 和直接登录 Anthropic 有什么区别?

A: 主要区别是:①计费走 OpenRouter 积分而非 Anthropic 订阅/API;②获得 Provider 故障转移能力;③可使用 OpenRouter 的团队积分管理和用量追踪功能。使用体验与直连 Anthropic 基本无差异。

Q: 是否支持所有 Claude 模型?

A: 通过 OpenRouter 可以访问 OpenRouter 平台上所有可用的 Claude 模型。建议优先使用 Anthropic 直连 Provider 以确保最佳兼容性(在 Provider 路由设置中将 Anthropic 1P 设为最高优先级)。

Q: 没有 Anthropic 账号可以使用吗?

A: 可以。Gateway 模式下选择 "Continue with Gateway" 而非用 Anthropic 账号登录,只需有效的 OpenRouter API key 即可。