GeezerVison is showing github.com — fix(provider): pass apiKey to createUnified for Cloudflare AI Gateway by keefetang · Pull Request #32052 · anomalyco/opencode
Conversation
keefetang
commented
Jun 12, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
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
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
i have tested the lest version for windows this feauture not added
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
panyw5
pushed a commit
to panyw5/opencode
that referenced
this pull request
Jul 3, 2026
rldona
pushed a commit
to plazoleta-dev/FlupCode
that referenced
this pull request
Sep 24, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.