Skip to content

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
mchenco:docs/cloudflare-providers
Open

docs+fix: add Cloudflare Workers AI / AI Gateway provider pages and unify CLOUDFLARE_API_TOKEN env var#9530
mchenco wants to merge 6 commits intoKilo-Org:mainfrom
mchenco:docs/cloudflare-providers

Conversation

@mchenco
Copy link
Copy Markdown
Contributor

@mchenco mchenco commented Apr 26, 2026

Context

Closes #9528.

The cloudflare-workers-ai and cloudflare-ai-gateway providers are already fully wired up in code. Just adding docs

Implementation

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.
Screenshot 2026-04-26 at 2 50 33 PM

Get in Touch

dm me @/michellechen on twitter

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
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@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
@mchenco mchenco changed the title docs: add Cloudflare Workers AI and Cloudflare AI Gateway provider pages docs+fix: add Cloudflare Workers AI / AI Gateway provider pages and unify CLOUDFLARE_API_TOKEN env var Apr 26, 2026
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).
Comment thread packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 27, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md 33 Legacy VS Code instructions still say "API Key" even though the provider now uses "API token" terminology throughout the implementation and docs.
Other Observations (not in diff)

No additional issues outside the diff.

Files Reviewed (6 files)
  • packages/kilo-docs/lib/nav/ai-providers.ts - 0 issues
  • packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md - 0 issues
  • packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md - 1 issue
  • packages/opencode/src/plugin/cloudflare.ts - 0 issues
  • packages/opencode/src/provider/provider.ts - 0 issues
  • packages/opencode/test/plugin/cloudflare.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by gpt-5.4-20260305 · 203,152 tokens

Comment thread packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md Outdated
Comment thread packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 27, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md 112 Internal cross-link uses /ai-providers/... instead of /docs/ai-providers/..., which points outside the docs section in production.
packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md 144 Internal cross-link uses /ai-providers/... instead of /docs/ai-providers/..., which points outside the docs section in production.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/kilo-docs/source-links.md 116 New Cloudflare docs URLs were added in this PR, but source-links.md was not regenerated, which is likely to fail the source-links CI check for docs URL changes. Fix these issues in Kilo Cloud
Files Reviewed (6 files)
  • packages/kilo-docs/lib/nav/ai-providers.ts - 0 issues
  • packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md - 1 issue
  • packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md - 1 issue
  • packages/opencode/src/plugin/cloudflare.ts - 0 issues
  • packages/opencode/src/provider/provider.ts - 0 issues
  • packages/opencode/test/plugin/cloudflare.test.ts - 0 issues

Reviewed by gpt-5.4-2026-03-05 · 1,108,076 tokens

Comment thread packages/opencode/src/provider/provider.ts Outdated
Comment thread packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 27, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-docs/lib/nav/ai-providers.ts
  • packages/kilo-docs/pages/ai-providers/cloudflare-ai-gateway.md
  • packages/kilo-docs/pages/ai-providers/cloudflare-workers-ai.md

Reviewed by gpt-5.5-2026-04-23 · 1,173,719 tokens

mchenco added 3 commits April 27, 2026 18:23
…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.
## Configuration in Kilo Code

{% tabs %}
{% tab label="VSCode (Legacy)" %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should remove the VSCode Legacy section.

{% /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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These instructions don't seem quite right. When I choose the Cloudflare AI Gateway provider, I only see an input for the api key field:

Image

I'm on the pre-release version of Kilo.

Authenticate interactively, or set environment variables:

```bash
kilo auth cloudflare-ai-gateway
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also doesn't work. It might be we haven't merged the behavior from opencode upstream yet. Here's what I'm seeing on the latest kilo cli:

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] kilo-docs: Cloudflare Workers AI and Cloudflare AI Gateway providers are fully implemented but missing from docs and sidebar nav

2 participants