Using Cloudflare With Kilo Code

Kilo Code supports both Cloudflare Workers AI and Cloudflare AI Gateway. Workers AI runs Cloudflare-hosted models directly, while AI Gateway routes requests through your Cloudflare gateway to one or more upstream providers.

Website: https://developers.cloudflare.com/ai/

Provider Options

Provider IDUse it forRequired values
cloudflare-workers-aiCloudflare-hosted Workers AI modelsAccount ID and API key
cloudflare-ai-gatewayRouting through Cloudflare AI GatewayAccount ID, Gateway ID, and Gateway API token

You can enter these values interactively with /connect in the TUI or kilo auth from the CLI, or provide them through environment variables.

Cloudflare Workers AI

Get Credentials

  1. Open the Cloudflare dashboard and select your account.
  2. Copy the Account ID from the dashboard.
  3. Create an API token that can invoke Workers AI.

Configure Kilo

Open Settings (gear icon) and go to the Providers tab to add Cloudflare Workers AI. If your account ID is not already available from the environment, Kilo prompts for it while connecting the provider.

Cloudflare AI Gateway

Get Credentials

  1. Create or open a Cloudflare AI Gateway.
  2. Copy your Account ID and Gateway ID.
  3. Create a Gateway API token.

Configure Kilo

Open Settings (gear icon) and go to the Providers tab to add Cloudflare AI Gateway. Kilo prompts for the account ID and gateway ID when they are not already set in the environment.

Advanced Configuration

If your organization provides a fully configured gateway URL, set provider.<id>.options.baseURL. When baseURL is configured, Kilo skips the built-in Account ID and Gateway ID checks because the URL already identifies the target service.

{
  "provider": {
    "cloudflare-ai-gateway": {
      "options": {
        "baseURL": "https://gateway.example.com/v1"
      }
    }
  }
}

Troubleshooting

  • CLOUDFLARE_ACCOUNT_ID is missing — set CLOUDFLARE_ACCOUNT_ID or reconnect the provider with /connect so Kilo can store the account ID in auth metadata.
  • CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID missing — set both values or run kilo auth cloudflare-ai-gateway.
  • CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required — set one of those variables or reconnect Cloudflare AI Gateway with kilo auth cloudflare-ai-gateway.
  • Model errors through AI Gateway — confirm the gateway route supports the selected upstream provider/model and that your Gateway API token has access.