GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway by keefetang · Pull Request #32052 · anomalyco/opencode

Conversation

@keefetang

@keefetang keefetang commented Jun 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #32051

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

createUnified() is called without an apiKey in the cloudflare-ai-gateway provider. The ai-gateway-provider package injects a placeholder CF_TEMP_TOKEN, then strips it before sending the universal endpoint request — leaving the Workers AI sub-request with no authorization header. This causes a 401 for all Workers AI models. BYOK models (Anthropic/OpenAI) are unaffected because they carry their own real API keys.

The fix passes the API key to createUnified({ apiKey }) so the real token is set on the sub-request Authorization header. The stripping logic only removes headers containing the literal CF_TEMP_TOKEN, so real tokens survive.

How did you verify your code works?

  • Reproduced the 401 by calling the AI Gateway universal endpoint with no auth in the sub-request headers
  • Applied the fix and confirmed Workers AI model requests now return 200
  • Verified BYOK models (Anthropic/OpenAI) are unaffected — their keys never contain CF_TEMP_TOKEN
  • Verified CF_TEMP_TOKEN stripping still works correctly for no-key/unified-billing scenarios
  • Verified cloudflare-workers-ai provider is a completely separate code path and untouched

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@keefetang
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway
d30486e
Workers AI models via cloudflare-ai-gateway fail with 401 because
createUnified() is called without an apiKey. The ai-gateway-provider
package injects CF_TEMP_TOKEN as a placeholder, then strips it before
sending — leaving the sub-request with no authorization header.

Passing the real API key means the Authorization header survives the
stripping logic and reaches the gateway correctly.

Fixes anomalyco#32051
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jun 13, 2026
feat(core): add OmniRoute custom provider support #32170
Closed
3 of 6 tasks
@rekram1-node
Merge branch 'dev' into fix/ai-gateway-workers-ai-auth
88e496f
@rekram1-node
rekram1-node merged commit 8fd5753 into anomalyco:dev Jun 16, 2026
6 of 8 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@kebiricrypto

kebiricrypto commented Jun 17, 2026

Copy link
Copy Markdown

i have tested the lest version for windows this feauture not added

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Jun 18, 2026
📊 AI CLI 工具社区动态日报 2026-06-18 zx0828/big_model_radar#141
Open
davidgut1982 pushed a commit to davidgut1982/opencode that referenced this pull request Jun 19, 2026
@keefetang @rekram1-node @davidgut1982
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway (…
9bc8933
…anomalyco#32052)

Co-authored-by: Aiden Cline <[email protected]>
LuisAlbertoMK pushed a commit to LuisAlbertoMK/opencode that referenced this pull request Jun 21, 2026
@keefetang @rekram1-node @LuisAlbertoMK
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway (…
a9c4be1
…anomalyco#32052)

Co-authored-by: Aiden Cline <[email protected]>
@ethulia ethulia mentioned this pull request Jun 22, 2026
fix(provider): scope AI Gateway token to workers-ai models #33407
Closed
3 of 6 tasks
@keefetang keefetang mentioned this pull request Jun 24, 2026
fix(provider): scope AI Gateway token to first-party Workers AI models #33597
Closed
3 of 6 tasks
BenGu3 pushed a commit to BenGu3/opencode that referenced this pull request Jun 27, 2026
@keefetang @rekram1-node @BenGu3
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway (…
18ab902
…anomalyco#32052)

Co-authored-by: Aiden Cline <[email protected]>
panyw5 pushed a commit to panyw5/opencode that referenced this pull request Jul 3, 2026
@keefetang @rekram1-node @panyw5
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway (…
cefca44
…anomalyco#32052)

Co-authored-by: Aiden Cline <[email protected]>
MarsQiu007 referenced this pull request in MarsQiu007/openNovel Jul 31, 2026
@keefetang @rekram1-node
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway…
a30c5cc
… (#32052)

Co-authored-by: Aiden Cline <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request Aug 6, 2026
docs: READMEとGitHub Packages公開用CIを追加 yohi/opencode-cloudflare-ai-gateway-byok#4
Merged
rldona pushed a commit to plazoleta-dev/FlupCode that referenced this pull request Sep 24, 2026
@keefetang @rekram1-node
fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway (…
716fe2a
…anomalyco#32052)

Co-authored-by: Aiden Cline <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

cloudflare-ai-gateway provider returns 401 for Workers AI models

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@keefetang @kebiricrypto @rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.