fix(proxy): dynamic pro model fallback with account-aware remapping - #2286
Merged
Merged
Conversation
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
This PR adds account-aware dynamic model remapping with fallback support for Gemini Pro model variants.
Changes
token_manager.rs: Addresolve_dynamic_model_for_account()method that detects when an account lacks access to a specific Pro tier (high/low) and automatically falls back to the available tier or preview endpointmodel_mapping.rs: Add explicit pass-through mappings for Gemini 3.x Pro variants (low/high/preview), with generic aliases routing to the preview entrypointhandlers/openai.rs&handlers/gemini.rs: Callresolve_dynamic_model_for_accountafter account selection to apply per-account model remappingmappers/common_utils.rs: Minor adjustment toapply_dynamic_model_remappingfor consistencydocs/model-remapping-logic.md: Add documentation explaining the remapping priority chainProblem Solved
When users have multiple accounts with different Gemini Pro tier access levels (some with
gemini-3.1-pro-high, some withgemini-3.1-pro-low), the proxy would route requests to the wrong tier or fail with 404/400 errors. This PR introduces account-aware fallback logic so the proxy automatically selects the best available model tier for each account.Remapping Priority Chain
Test plan
gemini-3.1-pro-highaccess correctly handle requests forgemini-3.1-pro-lowgemini-3-pro/gemini-3.1-pro(generic aliases) correctly route to*-previewgemini-3-pro-high/gemini-3-pro-low(concrete IDs) pass through unchangedcargo testfor the proxy module🤖 Generated with Claude Code