fix(ai-gateway): populate is_byok from Vercel gateway modelAttempts#3041
Open
kilo-code-bot[bot] wants to merge 2 commits intomainfrom
Open
fix(ai-gateway): populate is_byok from Vercel gateway modelAttempts#3041kilo-code-bot[bot] wants to merge 2 commits intomainfrom
kilo-code-bot[bot] wants to merge 2 commits intomainfrom
Conversation
Contributor
Author
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (2 files)
Reviewed by gpt-5.5-2026-04-23 · 259,950 tokens |
marius-kilocode
approved these changes
May 5, 2026
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
is_byok = nulleven though the gateway does report BYOK-vs-system credential information viaprovider_metadata.gateway.routing.modelAttempts[].providerAttempts[].credentialType. The messages, responses, and chat-completions code paths all hard-codedis_byok: nullon the Vercel branch.extractVercelIsByokinprocessUsage.shared.tsthat walks the successfulmodelAttempts → providerAttemptsand mapscredentialType("byok"→true,"system"→false, otherwisenull).processMessagesApiUsage,processResponsesApiUsage, andprocessOpenRouterUsage(used by chat completions) so that Vercel-served requests populateis_byokwhenever the gateway surfaces it. For chat completions we captureprovider_metadatafrom both stream chunks and the non-streaming JSON and forward it toprocessOpenRouterUsage.VercelProviderMetaDatatype withmodelAttempts/providerAttemptsshape. Updated approval fixtures and added unit tests coveringbyok,system, and the case where the first provider attempt fails.Verification
vercel-messages.log.resp.sse/vercel-responses.log.resp.ssefixtures: both containcredentialType: "byok"in the gateway routing, and the updated approval JSON now reflectsis_byok: true.Visual Changes
N/A
Reviewer Notes
modelAttemptsis absent (some upstream paths/providers may omit it), preserving the previousnullbehavior rather than guessing.usage.is_byokis set; the Vercel metadata is only consulted when OpenRouter didn't provide a value.