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 ID | Use it for | Required values |
|---|---|---|
cloudflare-workers-ai | Cloudflare-hosted Workers AI models | Account ID and API key |
cloudflare-ai-gateway | Routing through Cloudflare AI Gateway | Account 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
- Open the Cloudflare dashboard and select your account.
- Copy the Account ID from the dashboard.
- 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
- Create or open a Cloudflare AI Gateway.
- Copy your Account ID and Gateway ID.
- 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— setCLOUDFLARE_ACCOUNT_IDor reconnect the provider with/connectso Kilo can store the account ID in auth metadata.CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID missing— set both values or runkilo auth cloudflare-ai-gateway.CLOUDFLARE_API_TOKEN (or CF_AIG_TOKEN) is required— set one of those variables or reconnect Cloudflare AI Gateway withkilo 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.