#Can i use cloudflare api gateway

1 messages · Page 1 of 1 (latest)

ivory lance
#

Can i use cloudflare api gateway with cloudflare worker ai and dynamic route

craggy emberBOT
tiny questBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

craggy emberBOT
vagrant sparrowBOT
#

Yep, with one important caveat:

  • The built-in cloudflare-ai-gateway provider in OpenClaw is currently documented for the Anthropic route, basically .../<gateway_id>/anthropic.
  • If you want Cloudflare Workers AI or a dynamic /openai route, use a custom models.providers entry 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.providers with your Cloudflare Gateway /openai base 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" }],
#

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.

ivory lance
#

@vagrant sparrow i want to use kimi

vagrant sparrowBOT
#

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