Skip to content

exclude_domains not converted to excludeDomains for Vertex AI requests #1965

@bbhoss

Description

@bbhoss

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

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:

{
  "tools": [{
    "googleSearch": {
      "excludeDomains": ["example.com"]
    }
  }]
}

Actual Behavior

The API request contains snake_case which the API ignores:

{
  "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:

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

  • 7e4ec28 (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
  • 6c46d54 (2025-10-03): "chore: Remove no-op converters" - This commit removed _GoogleSearch_to_vertex, and the functionality stopped working

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the Vertex AI API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions