fix: show upstream model in user usage records when model mapping is applied#1454
Open
octo-patch wants to merge 2 commits intoWei-Shaw:mainfrom
Open
fix: show upstream model in user usage records when model mapping is applied#1454octo-patch wants to merge 2 commits intoWei-Shaw:mainfrom
octo-patch wants to merge 2 commits intoWei-Shaw:mainfrom
Conversation
… gateway (fixes Wei-Shaw#1430) When a GPT account's model mapping uses a non-standard name (e.g. "gpt" without version), RecordUsage could not find pricing and silently billed zero. Similarly, the Anthropic Messages compat path set BillingModel to the correct GPT model but RecordUsage ignored it, billing at Claude rates instead. Two changes to OpenAIGatewayService.RecordUsage: 1. Prefer result.BillingModel when set (non-empty), falling back to the existing forwardResultBillingModel logic. This ensures the Messages compat path (CC to GPT) uses the correct GPT pricing. 2. When the resolved billing model has no pricing configured, fall back to result.UpstreamModel before giving up. The upstream model is always normalised to a known model (e.g. "gpt-5.1"), so this prevents billing from silently dropping to zero for non-standard model names.
…ing is applied (fixes Wei-Shaw#1444) Previously, users could not see which model was actually used when model mapping was configured. The upstream_model field was only included in admin API responses. This change: - Adds upstream_model to the user-facing UsageLog DTO - Populates it from the service layer in usageLogFromServiceUser() - Updates UsageView.vue to display the mapped model (e.g. GPT-5.3-codex then GPT-5.4-mini) - Updates UserDashboardRecentUsage.vue to show the mapped model in the dashboard - Updates test to reflect the new behavior Co-Authored-By: Octopus <liyuan851277048@icloud.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.
Fixes #1444
Problem
When a model mapping is configured (e.g., GPT-5.3-codex → GPT-5.4-mini), the usage records shown to regular users only display the originally requested model name (GPT-5.3-codex), making it impossible to see which model was actually used. The
upstream_modelfield was available in the database and shown in admin views, but excluded from user-facing API responses.Solution
upstream_modelfield to the user-facingUsageLogDTO (previously it was admin-only)UpstreamModelinusageLogFromServiceUser()from the service layerUsageView.vueto display the mapped model below the requested model with an arrow indicator (↳) when a mapping was appliedUserDashboardRecentUsage.vueto also show the mapped model in the dashboard recent usage listUpstreamModelfromAdminUsageLoginto the baseUsageLogstruct since it's now sharedTesting
TestUsageLogFromService_UsesRequestedModelAndIncludesUpstreamModelupdated to verifyupstream_modelis now included in both user and admin JSON responsesupstream_modelis omitted (omitempty), so the display is unchanged for unmapped requests