Repository navigation
[AISAGE-733] fix(ai-gateway): stop warning about expected BYOK transcription cost mismatches - #8961
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe 5-line guard in Assumptions: Files Reviewed (2 files)
Reviewed by deepseek-flash-latest · Input: 102.3K · Output: 12K · Cached: 740.4K Review guidance: REVIEW.md from base branch |
joshburt
self-requested a review
October 27, 2026 14:45
joshburt
approved these changes
Oct 27, 2026
This was referenced Oct 28, 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
processTokenDatawarnsCost from provider generation lookup differs from cost computed from response usage datawhenever the OpenRouter/Vercel generation lookup cost differs from the response-derived cost, and then bills the generation cost.OpenRouter BYOK transcriptions report only
usage.cost, withoutis_byokorcost_details, so that cost is just OpenRouter's 5% BYOK fee (seeparseTranscriptionUsageFromResponseinllm-proxy-helpers.ts, #8877). The generation lookup reportsis_byok: trueand the full upstream cost, so every successful BYOK transcription logged this warning with a roughly 20× mismatch (for example{ generation: 467, response: 23 }formistralai/voxtral-small-transcribe-3-0). Billing was already correct; the warning was noise that looked like a billing bug.This skips the warning only when the response did not report BYOK status (
is_byok == null) and the generation lookup reportsis_byok === true. All other mismatches still warn. The billed cost and theSUSPICIOUS: OpenRouter generation lookup failed...path are unchanged.Verification
pnpm --filter web test -- ../../packages/web-shared/src/lib/ai-gateway/processUsage.test.ts(90 passed), including:pnpm --filter @kilocode/web-shared typecheckoxlint --config .oxlintrc.json packages/web-shared/srcpnpm formatModels
Written with Claude Opus 5.5 (
kilo/anthropic/claude-opus-5.5); no subagents were used.