Cloudflare AI Gateway sits in front of provider APIs and lets you add analytics, caching, and controls. For Anthropic, OpenClaw uses the Anthropic Messages API through your Gateway endpoint.
CLOUDFLARE_AI_GATEWAY_API_KEY (your provider API key for requests through the Gateway)
For Anthropic models routed through Cloudflare AI Gateway, use your Anthropic API key as the provider key.
When thinking is enabled for Anthropic Messages models, OpenClaw strips trailing
assistant prefill turns before sending the payload through Cloudflare AI Gateway.
Anthropic rejects response prefilling with extended thinking, while ordinary
non-thinking prefill remains available.
The cf-aig-authorization header authenticates with the Cloudflare Gateway itself, while the provider API key (for example, your Anthropic key) authenticates with the upstream provider.
Environment note
If the Gateway runs as a daemon (launchd/systemd), make sure CLOUDFLARE_AI_GATEWAY_API_KEY is available to that process.
A key sitting only in ~/.profile will not help a launchd/systemd daemon unless that environment is imported there as well. Set the key in ~/.openclaw/.env or via env.shellEnv to ensure the gateway process can read it.