googleapis / googleapis/python-genai
exclude_domains not converted to excludeDomains for Vertex AI requests
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
## Description
When using Google Search grounding with Vertex AI, the `exclude_domains` parameter is not being converted to `excludeDomains` (camelCase) in the API request, causing the parameter to be silently ignored.
## Steps to Reproduce
```python
from google import genai
from google.genai import types
client = genai.Client(vertexai=True)
config = types.GenerateContentConfig(
temperature=0.5,
max_output_tokens=100,
tools=[
types.Tool(
google_search=types.GoogleSearch(
exclude_domains=["example.com"]
)
)
],
)
response = client.models.generate_content(
model="gemini-2.5-flash-lite",
contents="Search the web for something",
config=config,
)
```
## Expected Behavior
The API request should contain:
```json
{
"tools": [{
"googleSearch": {
"excludeDomains": ["example.com"]
}
}]
}
```
## Actual Behavior
The API request contains snake_case which the API ignores:
```json
{
"tools": [{
"googleSearch": {
"exclude_domains": ["example.com"]
}
}]
}
```
The excluded domains are not respected - search results still include content from the specified domains.
## How I Debugged This
I patched `httpx.Client.send` to inspect the request body being sent to the Vertex AI API:
```python
import httpx
import json
original_send = httpx.Client.send
def patched_send(self, request, **kwargs):
if 'aiplatform' in str(request.url) and request.content:
data = json.loads(request.content)
print('REQUEST:', json.dumps(data.get('tools', []), indent=2))
return original_send(self, request, **kwargs)
httpx.Client.send = patched_send
```
This revealed that `exclude_domains` is not being converted to `excludeDomains` for the nested GoogleSearch object, even though the parent key `google_search` is correctly converted to `googleSearch`.
## Version Information
- google-genai: 1.59.0
- Python: 3.13
## Relevant Commits
- **7e4ec284** (2025-08-13): "feat: Support exclude_domains in Google Search and Enterprise Web Search" - This commit added `_GoogleSearch_to_vertex` which properly converted `exclude_domains` to `excludeDomains`
- **6c46d54b** (2025-10-03): "chore: Remove no-op converters" - This commit removed `_GoogleSearch_to_vertex`, and the functionality stopped working
Contributor guide
Assessment
This issue has not been assessed yet.