This commit is contained in:
Paulo 2026-09-15 16:46:27 -03:00 • committed by GitHub
commit 3b4ec93653
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View file

@ -76,6 +76,9 @@ class ContextCachingEndpoints(VertexBase):
base_url = get_vertex_base_url(vertex_location)
url = f"{base_url}/v1beta1/projects/{vertex_project}/locations/{vertex_location}/{endpoint}"
if custom_llm_provider == "gemini" and api_base:
return auth_header, f"{api_base.rstrip('/')}/{endpoint}"
return self._check_custom_proxy(
api_base=api_base,
custom_llm_provider=custom_llm_provider,

View file

@ -2027,12 +2027,7 @@ class TestVertexAIGlobalLocation:
"global-aiplatform" not in url
), "URL should not contain 'global-aiplatform' prefix"
def test_gemini_context_caching_with_custom_api_base_passes_model(self):
"""Gemini context caching with custom api_base must pass model to _check_custom_proxy.
Regression test for https://github.com/BerriAI/litellm/issues/23846
Previously model was hardcoded to None, causing ValueError when api_base was set.
"""
def test_gemini_custom_cache_uses_collection_endpoint_without_model(self):
caching = ContextCachingEndpoints()
auth_header, url = caching._get_token_and_url_context_caching(
@ -2042,11 +2037,10 @@ class TestVertexAIGlobalLocation:
vertex_project=None,
vertex_location=None,
vertex_auth_header=None,
model="gemini-1.5-pro",
)
assert "models/gemini-1.5-pro" in url
assert url.startswith("https://my-proxy.example.com/")
assert auth_header == {"x-goog-api-key": "test-key"}
assert url == "https://my-proxy.example.com/cachedContents"
def test_gemini_context_caching_without_api_base_ignores_model(self):
"""Without custom api_base, model param is not needed (default URL is used)."""