-
Notifications
You must be signed in to change notification settings - Fork 784
Open
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment
google-genaiversion: 1.64.0- Python: 3.13.2
Description
When a custom base_url is passed (e.g. via langchain-google-genai's ChatGoogleGenerativeAI),
the SDK internally sets _http_options.api_version = "v1beta" and appends it to the base URL
when constructing request paths.
This makes it impossible to use an enterprise reverse proxy (e.g. WSO2 API Gateway) that exposes
the Gemini API at a clean path without the /v1beta segment, because every request ends up routed
to a non-existent path on the proxy.
Reproduction
from google import genai
client = genai.Client(
api_key="unused",
http_options={"base_url": "https://my-proxy.example.com/gemini/"},
)
#Actual requests go to: https://my-proxy.example.com/gemini/v1beta/models/...
#Expected: https://my-proxy.example.com/gemini/models/...Current workaround
# Directly mutate internal state after construction — fragile against SDK updates
client._api_client._http_options.api_version = ""
Expected behavior
http_options should expose an api_version field (or equivalent) that is honoured when a
base_url is explicitly set, defaulting to "" when the caller opts into a fully-qualified base
URL. Alternatively, if base_url already contains the version segment the SDK should not append it
again.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.