#Can i use cloudflare api gateway
1 messages · Page 1 of 1 (latest)
Yep, with one important caveat:
- The built-in
cloudflare-ai-gatewayprovider in OpenClaw is currently documented for the Anthropic route, basically.../<gateway_id>/anthropic. - If you want Cloudflare Workers AI or a dynamic
/openairoute, use a custommodels.providersentry instead of the built-in provider.
So the short answer is:
- Anthropic through Cloudflare AI Gateway → use the built-in provider.
- Workers AI / dynamic OpenAI-compatible route → use
models.providerswith your Cloudflare Gateway/openaibase URL.
Example shape:
{
agents: {
defaults: {
model: { primary: "cf-openai/your-model-id" },
},
},
models: {
mode: "merge",
providers: {
"cf-openai": {
baseUrl: "https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/openai",
api: "openai-completions",
apiKey: "${YOUR_API_KEY}",
headers: {
// only if your Cloudflare gateway auth is enabled
// "cf-aig-authorization": "Bearer <gateway-token>",
},
models: [{ id: "your-model-id", name: "Cloudflare route" }],
},
},
},
}
A couple of gotchas:
- This only works if the Cloudflare route is actually OpenAI-compatible.
- Proxy routes do not get native OpenAI-only extras in OpenClaw.
- If you're using non-Anthropic models for heavier tool calling, reliability can be a bit rougher.
Docs:
If you want, paste your exact Cloudflare route setup, like /anthropic, /openai, dynamic route, Workers AI model, and I’ll turn it into the exact OpenClaw config.
@vagrant sparrow i want to use kimi
Yes — for Kimi via Cloudflare, use Cloudflare’s OpenAI-compatible compat/chat/completions endpoint as a custom OpenClaw provider. Don’t use OpenClaw’s built-in cloudflare-ai-gateway provider for this; that one is currently documented for Anthropic-through-Cloudflare. (docs.openclaw.ai)
Cloudflare Dynamic Routes are called by putting the route name in the model field, e.g. dynamic/support. (developers.cloudflare.com) Cloudflare Workers AI also exposes Kimi as @cf/moonshotai/kimi-k2.5, and Workers AI supports OpenAI-compatible chat completions. (developers.cloudflare.com)
Example shape:
{
models: {
providers: {
"cloudflare-compat": {
baseUrl: "https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_id>/compat",
api: "openai-completions",
apiKey: "${CLOUDFLARE_AUTH_TOKEN}",
authHeader: true,
headers: {
// only if AI Gateway auth is enabled:
"cf-aig-authorization": "Bearer <CF_AIG_TOKEN>"
},
models: [
{
id: "dynamic/<your-route-name>",
name: "Cloudflare Dynamic Route",
input: ["text", "image"],
contextWindow: 256000
}
// or direct Workers AI Kimi:
// { id: "workers-ai/@cf/moonshotai/kimi-k2.5", name: "Kimi K2.5" }
]
}
}
},
agents: {
defaults: {
model: { primary: "cloudflare-compat/dynamic/<your-route-name>" }
}
}
}
If you don’t specifically need Cloudflare routing, the simpler supported path is direct Kimi/Moonshot:
openclaw onboard --auth-choice moonshot-api-key
openclaw models set moonshot/kimi-k2.6