Cloudflare AI gateway
Cloudflare AI Gateway(网关) 位于提供商 API 之前,允许您添加分析、缓存和控件。对于 Anthropic,OpenClaw 通过您的 Gateway(网关) 端点使用 Anthropic Messages API。
| 属性 | 值 |
|---|---|
| 提供商 | cloudflare-ai-gateway |
| 基础 URL | https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/anthropic |
| 默认模型 | cloudflare-ai-gateway/claude-sonnet-4-6 |
| API 密钥 | CLOUDFLARE_AI_GATEWAY_API_KEY(您的提供商 API 密钥,用于通过 Gateway(网关) 的请求) |
当为 Anthropic Messages 模型启用思考功能时,OpenClaw 会在通过 Cloudflare AI Gateway(网关) 发送有效负载之前,去除尾随的助手预填充轮次。Anthropic 拒绝带有扩展思考的响应预填充,而普通的非思考预填充仍然可用。
设置提供商 API 密钥和 Gateway(网关) 详细信息
运行新手引导并选择 Cloudflare AI Gateway(网关) 身份验证选项:
Terminal window openclaw onboard --auth-choice cloudflare-ai-gateway-api-key此时会提示您输入帐户 ID、网关 ID 和 API 密钥。
设置默认模型
将模型添加到您的 OpenClaw 配置中:
{agents: {defaults: {model: { primary: "cloudflare-ai-gateway/claude-sonnet-4-6" },},},}验证模型可用性
Terminal window openclaw models list --provider cloudflare-ai-gateway
非交互式示例
Section titled “非交互式示例”对于脚本或 CI 设置,请在命令行中传递所有值:
openclaw onboard --non-interactive \ --mode local \ --auth-choice cloudflare-ai-gateway-api-key \ --cloudflare-ai-gateway-account-id "your-account-id" \ --cloudflare-ai-gateway-gateway-id "your-gateway-id" \ --cloudflare-ai-gateway-api-key "$CLOUDFLARE_AI_GATEWAY_API_KEY"已验证身份的网关
如果您在 Cloudflare 中启用了 Gateway(网关) 身份验证,请添加 cf-aig-authorization 标头。这是除您的提供商 API 密钥之外的附加项。
{ models: { providers: { "cloudflare-ai-gateway": { headers: { "cf-aig-authorization": "Bearer”, }, }, }, }, } ```
环境说明
如果 Gateway(网关) 作为守护进程(launchd/systemd)运行,请确保 CLOUDFLARE_AI_GATEWAY_API_KEY 对该进程可用。
模型选择
选择提供商、模型引用和故障转移行为。
故障排除
常规故障排除和常见问题。