feat(tanstack-ai): add REST-only byokAlias for stored BYOK keys - #638
Open
L4Ph wants to merge 5 commits into
Open
feat(tanstack-ai): add REST-only byokAlias for stored BYOK keys#638L4Ph wants to merge 5 commits into
L4Ph wants to merge 5 commits into
Conversation
cf-aig-byok-alias is a provider-passthrough header. Expose it on credentials config so OpenAI, Anthropic, Grok, OpenRouter, and Workers AI gateway REST can select a non-default stored key. The AI binding type omits it because that path does not honor the header for third-party models. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 45b80c3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Gemini is credentials / provider-passthrough only, so cf-aig-byok-alias is honored. Map it through httpOptions.headers like the other cache headers — it never went through createGatewayFetch. Co-authored-by: Cursor <cursoragent@cursor.com>
Restore the original tab style after the previous edit rewrote those files with spaces. Behavior is unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
Every gateway adapter already intersects AiGatewayConfig. Keep the field there so OpenAI, Anthropic, Grok, OpenRouter, Workers AI, and Gemini share one type. Gemini still maps the header itself because it cannot use createGatewayFetch. Co-authored-by: Cursor <cursoragent@cursor.com>
The previous commit rewrote the file with spaces. Behavior is unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
byokAliason AI Gateway credentials / REST config socreateOpenAiChat,createAnthropicChat,createGeminiChat,createGrokChat,createOpenRouterChat, and Workers AI gateway REST can sendcf-aig-byok-aliasand select a stored BYOK key other thandefault.env.AI.run()/ Unified Billing).httpOptions.headers(Google GenAI SDK has no customfetch).Test plan
pnpm --filter @cloudflare/tanstack-ai exec vitest --run test/gateway-fetch.test.ts test/gateway-adapters.test.ts(66 passed)createGatewayFetchsetscf-aig-byok-aliason the outer requestbyokAliasis forced through the typecreateOpenRouterChat/createOpenAiChat/createAnthropicChatHTTPClient fetchers forward the aliascreateGeminiChatforwards the alias viahttpOptions.headers