-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix URL construction bug and add proxy server warnings for Gemini models #13698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix URL construction bug and add proxy server warnings for Gemini models #13698
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
) | ||
raise VertexAIError( | ||
status_code=error_code, | ||
message=f"{err.response.text or 'Not Found'} | {hint}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will throw an error on python 3.8
can you avoid using |
@@ -301,7 +301,7 @@ def _check_custom_proxy( | |||
""" | |||
if api_base: | |||
if custom_llm_provider == "gemini": | |||
url = "{}:{}".format(api_base, endpoint) | |||
url = "{}/{}".format(api_base.rstrip("/"), endpoint.lstrip("/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the :
is for google ai studio calls because that's how the endpoint is constructed.
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
see :generateContent
Your changes would cause these requests to fail @kankute-sameer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current pr would break for google ai studio
@@ -301,7 +301,7 @@ def _check_custom_proxy( | |||
""" | |||
if api_base: | |||
if custom_llm_provider == "gemini": | |||
url = "{}:{}".format(api_base, endpoint) | |||
url = "{}/{}".format(api_base.rstrip("/"), endpoint.lstrip("/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api_base
+ endpoint
seems to still be missing the model information
If api_base=https://api.example.com/v1beta
, appending the generateContent
endpoint results in the URL https://api.example.com/v1beta:generateContent
.
Fix URL construction bug and add proxy server warnings for Gemini models
Relevant issues
Fixes #13693 - Invalid port error when using Gemini models with LiteLLM proxy server
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🐛 Bug Fix
🧹 Refactoring
Changes
Bug Fix: URL Construction Error
_check_custom_proxy
method"{}:{}".format(api_base, endpoint)
to"{}/{}".format(api_base.rstrip('/'), endpoint.lstrip('/'))
Invalid port: '4000:generateContent'
errorEnhanced Error Handling
api_base
We have NOT fixed the fundamental architectural issue where Gemini models automatically route to
/generateContent
endpoints when using a LiteLLM proxy server.What Still Happens
/generateContent
endpointcustom_llm_provider="openai"
as a workaroundWhy This Can't Be Fully Fixed Here
This is a design-level architectural mismatch between:
api_base
forvertex_ai_beta
models #4317)