{"id":214,"date":"2026-03-21T22:47:22","date_gmt":"2026-03-21T14:47:22","guid":{"rendered":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/providers-cloudflare-ai-gateway\/"},"modified":"2026-03-21T23:30:48","modified_gmt":"2026-03-21T15:30:48","slug":"providers-cloudflare-ai-gateway","status":"publish","type":"post","link":"https:\/\/pa.yingzhi8.cn\/index.php\/2026\/03\/21\/providers-cloudflare-ai-gateway\/","title":{"rendered":"Cloudflare AI \u7f51\u5173"},"content":{"rendered":"<h1>Cloudflare AI Gateway<\/h1>\n<p>Cloudflare AI Gateway \u4f4d\u4e8e\u63d0\u4f9b\u5546 API \u524d\u65b9\uff0c\u8ba9\u4f60\u80fd\u591f\u6dfb\u52a0\u5206\u6790\u3001\u7f13\u5b58\u548c\u63a7\u5236\u529f\u80fd\u3002\u5bf9\u4e8e Anthropic\uff0cOpenClaw \u4f1a\u901a\u8fc7\u4f60\u7684 Gateway \u7aef\u70b9\u4f7f\u7528 Anthropic Messages API\u3002<\/p>\n<ul>\n<li>\u63d0\u4f9b\u5546\uff1a<code>cloudflare-ai-gateway<\/code><\/li>\n<li>Base URL\uff1a<code>https:\/\/gateway.ai.cloudflare.com\/v1\/&lt;account_id&gt;\/&lt;gateway_id&gt;\/anthropic<\/code><\/li>\n<li>\u9ed8\u8ba4\u6a21\u578b\uff1a<code>cloudflare-ai-gateway\/claude-sonnet-4-5<\/code><\/li>\n<li>API key\uff1a<code>CLOUDFLARE_AI_GATEWAY_API_KEY<\/code>\uff08\u4f60\u7528\u4e8e\u901a\u8fc7 Gateway \u53d1\u8d77\u8bf7\u6c42\u7684\u63d0\u4f9b\u5546 API key\uff09<\/li>\n<\/ul>\n<p>\u5bf9\u4e8e Anthropic \u6a21\u578b\uff0c\u8bf7\u4f7f\u7528\u4f60\u7684 Anthropic API key\u3002<\/p>\n<h2>\u5feb\u901f\u5f00\u59cb<\/h2>\n<ol>\n<li>\u8bbe\u7f6e\u63d0\u4f9b\u5546 API key \u548c Gateway \u8be6\u7ec6\u4fe1\u606f\uff1a<\/li>\n<\/ol>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw onboard &#8211;auth-choice cloudflare-ai-gateway-api-key<\/p>\n<pre><code>\n2. \u8bbe\u7f6e\u9ed8\u8ba4\u6a21\u578b\uff1a\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  agents: {\n    defaults: {\n      model: { primary: &quot;cloudflare-ai-gateway\/claude-sonnet-4-5&quot; },\n    },\n  },\n}\n<\/code><\/pre>\n<h2>\u975e\u4ea4\u4e92\u5f0f\u793a\u4f8b<\/h2>\n<p>&#8220;`bash  theme={&#8220;theme&#8221;:{&#8220;light&#8221;:&#8221;min-light&#8221;,&#8221;dark&#8221;:&#8221;min-dark&#8221;}}<br \/>\nopenclaw onboard &#8211;non-interactive<br \/>\n  &#8211;mode local<br \/>\n  &#8211;auth-choice cloudflare-ai-gateway-api-key<br \/>\n  &#8211;cloudflare-ai-gateway-account-id &#8220;your-account-id&#8221;<br \/>\n  &#8211;cloudflare-ai-gateway-gateway-id &#8220;your-gateway-id&#8221;<br \/>\n  &#8211;cloudflare-ai-gateway-api-key &#8220;$CLOUDFLARE_AI_GATEWAY_API_KEY&#8221;<\/p>\n<pre><code>\n## \u5df2\u8ba4\u8bc1\u7684 Gateway\n\n\u5982\u679c\u4f60\u5728 Cloudflare \u4e2d\u542f\u7528\u4e86 Gateway \u8ba4\u8bc1\uff0c\u8bf7\u6dfb\u52a0 `cf-aig-authorization` header\uff08\u8fd9\u662f\u5728\u4f60\u7684\u63d0\u4f9b\u5546 API key \u4e4b\u5916\u989d\u5916\u6dfb\u52a0\u7684\uff09\u3002\n\n```json5  theme={&quot;theme&quot;:{&quot;light&quot;:&quot;min-light&quot;,&quot;dark&quot;:&quot;min-dark&quot;}}\n{\n  models: {\n    providers: {\n      &quot;cloudflare-ai-gateway&quot;: {\n        headers: {\n          &quot;cf-aig-authorization&quot;: &quot;Bearer &lt;cloudflare-ai-gateway-token&gt;&quot;,\n        },\n      },\n    },\n  },\n}\n<\/code><\/pre>\n<h2>\u73af\u5883\u8bf4\u660e<\/h2>\n<p>\u5982\u679c Gateway \u4f5c\u4e3a\u5b88\u62a4\u8fdb\u7a0b\u8fd0\u884c\uff08launchd\/systemd\uff09\uff0c\u8bf7\u786e\u4fdd <code>CLOUDFLARE_AI_GATEWAY_API_KEY<\/code> \u5bf9\u8be5\u8fdb\u7a0b\u53ef\u7528\uff08\u4f8b\u5982\u653e\u5728 <code>~\/.openclaw\/.env<\/code> \u4e2d\uff0c\u6216\u901a\u8fc7 <code>env.shellEnv<\/code> \u63d0\u4f9b\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cloudflare AI Gateway Cloudflare AI Gateway \u4f4d\u4e8e\u63d0\u4f9b\u5546 API \u524d [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-docs"],"_links":{"self":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/comments?post=214"}],"version-history":[{"count":2,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/posts\/214\/revisions\/889"}],"wp:attachment":[{"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pa.yingzhi8.cn\/index.php\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}