docs+fix: add Cloudflare Workers AI / AI Gateway provider pages and unify CLOUDFLARE_API_TOKEN env var#9530
Open
mchenco wants to merge 6 commits intoKilo-Org:mainfrom
Open
docs+fix: add Cloudflare Workers AI / AI Gateway provider pages and unify CLOUDFLARE_API_TOKEN env var#9530mchenco wants to merge 6 commits intoKilo-Org:mainfrom
mchenco wants to merge 6 commits intoKilo-Org:mainfrom
Conversation
Both providers were already fully wired up in code (auth plugins, custom loaders, ai-gateway-provider dep, models in models.dev, icons, and existing AI Gateway plugin tests) but had no docs pages or sidebar nav entries, so users couldn't discover or configure them. - Add packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md covering credentials, env vars (CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_KEY), supported models, and prefix caching via the x-session-affinity header that Kilo already sets per session. - Add packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md covering the required Gateway name (CLOUDFLARE_GATEWAY_ID), token setup (CLOUDFLARE_API_TOKEN / CF_AIG_TOKEN), Unified API model-id format (provider/model), and gateway-side caching options. - Wire both pages into packages/kilo-docs/lib/nav/ai-providers.ts under AI Gateways and Cloud Providers respectively. - Add CloudflareWorkersAuthPlugin tests and broader prompt-presence tests for CloudflareAIGatewayAuthPlugin to mirror the existing test coverage for the AI Gateway chat.params hook. Closes Kilo-Org#9528
|
@mchenco is attempting to deploy a commit to the Kilo Code Team on Vercel. A member of the Team first needs to authorize it. |
The cloudflare-workers-ai loader previously read only CLOUDFLARE_API_KEY, while cloudflare-ai-gateway reads CLOUDFLARE_API_TOKEN (with CF_AIG_TOKEN fallback). CLOUDFLARE_API_TOKEN is the canonical Cloudflare env var used by wrangler, terraform-provider-cloudflare, and the official Cloudflare docs (CLOUDFLARE_API_KEY was for the deprecated 'Global API Key'). Make Workers AI accept CLOUDFLARE_API_TOKEN first, falling back to CLOUDFLARE_API_KEY for backward compatibility, so a single environment variable works for both Cloudflare providers. Also rename the auth-method label from 'API key' to 'API token' for consistency with the AI Gateway plugin and Cloudflare nomenclature, and update the Workers AI docs to lead with CLOUDFLARE_API_TOKEN. Refs Kilo-Org#9528
The cloudflare-workers-ai and cloudflare-ai-gateway custom loaders sent 'User-Agent: opencode/<KILO_VERSION> ...' which mis-identified Kilo traffic as opencode in Cloudflare analytics. Mirror the kilo/ prefix the GitLab provider already uses (see line 557).
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Other Observations (not in diff)No additional issues outside the diff. Files Reviewed (6 files)
Fix these issues in Kilo Cloud Reviewed by gpt-5.4-20260305 · 203,152 tokens |
Contributor
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (6 files)
Reviewed by gpt-5.4-2026-03-05 · 1,108,076 tokens |
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by gpt-5.5-2026-04-23 · 1,173,719 tokens |
…data - docs/cloudflare-workers-ai.md: "API Key" -> "API Token" in step 3, matching the rest of the page and the canonical CLOUDFLARE_API_TOKEN env var. - docs/cloudflare-workers-ai.md, docs/cloudflare-ai-gateway.md: prefix internal links with /docs to match the rest of the provider docs. - opencode/src/provider/models.ts: surface the canonical CLOUDFLARE_API_TOKEN in cloudflare-workers-ai's provider.env (used by 'kilo auth list'), overriding the upstream models.dev snapshot which still lists the legacy CLOUDFLARE_API_KEY. Runtime loader in provider.ts continues to accept both env names.
Kilocode upstream already has full Workers AI and AI Gateway provider support in packages/opencode/. The original goal of this PR was just to add user-facing docs; the env-var alias, label, User-Agent, and metadata overrides drifted in mid-PR and aren't strictly necessary. Reverts to upstream/main: - packages/opencode/src/plugin/cloudflare.ts (label "API token" -> "API key") - packages/opencode/src/provider/provider.ts (drop CLOUDFLARE_API_TOKEN alias, restore opencode/ User-Agent) - packages/opencode/src/provider/models.ts (drop the env-array override) - packages/opencode/test/plugin/cloudflare.test.ts (drop new test cases) Also fixes the gateway docs link to point at the new Cloudflare URL: - /ai-gateway/usage/unified-api/ -> /ai-gateway/usage/chat-completion/ Net diff vs upstream/main is now docs + nav only: - packages/kilo-docs/lib/nav/ai-providers.ts - packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md - packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md If a follow-up PR for the polish (CLOUDFLARE_API_TOKEN alias, accurate label, kilo-branded UA) is wanted, it can be filed separately so docs review and provider-behavior review are not coupled.
jrf0110
reviewed
Apr 28, 2026
| ## Configuration in Kilo Code | ||
|
|
||
| {% tabs %} | ||
| {% tab label="VSCode (Legacy)" %} |
Contributor
There was a problem hiding this comment.
Should remove the VSCode Legacy section.
jrf0110
reviewed
Apr 28, 2026
| {% /tab %} | ||
| {% tab label="VSCode" %} | ||
|
|
||
| Open **Settings** (gear icon) and go to the **Providers** tab to add Cloudflare AI Gateway. You'll be prompted for your Account ID, Gateway name, and API token. |
Contributor
jrf0110
reviewed
Apr 28, 2026
| Authenticate interactively, or set environment variables: | ||
|
|
||
| ```bash | ||
| kilo auth cloudflare-ai-gateway |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Context
Closes #9528.
The
cloudflare-workers-aiandcloudflare-ai-gatewayproviders are already fully wired up in code. Just adding docsImplementation
Docs (new + nav)
packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md(new)packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md(new)packages/kilo-docs/lib/nav/ai-providers.ts— adds Cloudflare AI Gateway under AI Gateways and Cloudflare Workers AI under Cloud Providers.Get in Touch
dm me @/michellechen on twitter