googleapis / googleapis/python-genai
vertexai's request path is not appended to the url when using a custom base_url
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
This started to happen with 1.47 and is still the case as of the latest version (1.61 now)
this was the change that causes it: https://github.com/googleapis/python-genai/commit/7bd1bdef36179d404f671926df624afc5be5682d#diff-4c1a4bac9ab6ed029428abb29a40ab24b267b55c306720b2113dca092cd14625R1071
`join_url_path` is not called on every case now, and the combination of vertex ai + custom base url results in the url never being correctly built
reproducer using the example from the library's own documentation
```python
base_url = 'http://localhost:8080'
client = Client(
vertexai=True, # Currently only vertexai=True is supported
http_options={
'base_url': base_url,
'headers': {'Authorization': 'Bearer test_token'},
},
)
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents="Why is the sky blue? explain with an image",
)
```
this results in a `POST http://localhost:8080`
but it should be `POST http://localhost:8080/v1beta1/publishers/google/models/gemini-2.5-flash-image:generateContent`
There is a workaround to make it correctly append the path, by adding a dummy api key
```python
client =Client(
vertexai=True,
api_key="dummy", # <----
http_options={
"base_url": base_url,
"headers": {"Authorization": f"Bearer test-token"},
},
)
```
and there is already a PR that tries to address it https://github.com/googleapis/python-genai/pull/1701 , but it adds an extra param to hammer it in place, while probably the library should handle all the combinations directly in `_build_request` and not require the user to force certain behavior
creating the issue because i couldn't find anything referencing it other than the PR itself
Contributor guide
Assessment
This issue has not been assessed yet.