Claude Desktop ↗ 可以将第三方推理请求发送到自定义 gateway。此配置会将这些请求发送到 AI Gateway 的 Anthropic 端点,并使用 Cloudflare gateway 令牌进行身份验证。AI Gateway 可通过 Unified Billing 或已存储的提供商密钥(BYOK)为你提供 Anthropic 凭据。
开始之前,你需要:
- 一个已认证的 gateway 及其 gateway 令牌。该 gateway 令牌必须具有
Run权限。 - 你的 Cloudflare 账户 ID。查找方法请参阅查找账户和 zone ID。
- Anthropic 请求的凭据。使用 Unified Billing 积分,或将 Anthropic API 密钥作为提供商密钥(BYOK)存储在 AI Gateway 中。
- 已安装并更新到最新版本的 Claude Desktop。
-
在 Claude Desktop 中,选择 Help(帮助) > Troubleshooting(故障排除) > Enable Developer Mode(启用开发者模式)。
-
选择 Developer(开发者) > Configure Third-Party Inference(配置第三方推理)。
-
在 Connection(连接) 中,将连接类型设为 Gateway。
-
在 Gateway credentials(网关凭据) 中,将 Credential kind(凭据类型) 设为 Static API key(静态 API 密钥)。
-
将 Gateway API key(网关 API 密钥) 设为你的 Cloudflare gateway 令牌。
将
<CF_AIG_TOKEN>替换为你的 gateway 令牌。<CF_AIG_TOKEN> -
将 Gateway auth scheme(网关身份验证方案) 设为 Bearer。
-
将 gateway base URL 设为你的 gateway 的 Anthropic 端点。
将
<ACCOUNT_ID>和<GATEWAY_ID>替换为你的值。https://gateway.ai.cloudflare.com/v1/<ACCOUNT_ID>/<GATEWAY_ID>/anthropic -
在 Models(模型) 中,添加要使用的 Claude 模型。
字段 值 Model ID claude-sonnet-4-5Display name Claude Sonnet 4.5Tier alias sonnet -
在 Gateway credentials(网关凭据) 中,选择 Test connection(测试连接)。
-
开始 Claude Desktop 对话。请求现在会通过 AI Gateway 路由。
要确认流量已到达 AI Gateway,请参阅验证是否生效。