fix: allow custom Gemini models instead of strict list check#94
Open
bluzername wants to merge 1 commit into1rgs:mainfrom
Open
fix: allow custom Gemini models instead of strict list check#94bluzername wants to merge 1 commit into1rgs:mainfrom
bluzername wants to merge 1 commit into1rgs:mainfrom
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.
Problem
When using a newer or custom Gemini model (like
gemini-3.1-flash-lite-preview) by settingPREFERRED_PROVIDER="google"and definingSMALL_MODEL/BIG_MODELin.env, the proxy fails with OpenAI 401 error because it doesnt recognize the model as Gemini.I was trying to use
gemini-3.1-flash-lite-previewwhich is newer model not in the hardcoded list and the proxy kept sending my requests to OpenAI with the dummy API key instead of Google.Root Cause
The
GEMINI_MODELSlist inserver.pyonly containsgemini-2.5-flashandgemini-2.5-pro. Any model not in this strict list falls through to the OpenAI path, even if the model name clearly starts with "gemini".This happens in 6 places across two validators (
MessagesRequestandTokenCountRequest):SMALL_MODEL in GEMINI_MODELSBIG_MODEL in GEMINI_MODELSclean_v in GEMINI_MODELSFix
Added
is_gemini_model()helper that checks both the known list ANDstartswith("gemini"):Replaced all 6 occurrences of
in GEMINI_MODELSwithis_gemini_model(). This way:gemini-3.1-flash-lite-previeware correctly routed to Google instead of falling back to OpenAIGEMINI_MODELSlist stays as a reference but is no longer the only gatePython syntax verified.
Closes #87