Repository navigation
DiscoveryEngineSearchTool: 400 error with regional (non-global) data stores #4697
Description
Description
DiscoveryEngineSearchTool fails with a 400 error when used with a data store located in a non-global region (e.g. eu).
Error
400 Incorrect API endpoint used. The current endpoint can only serve traffic from "global" region,
but got "eu" region from the API request.
Please follow https://cloud.google.com/generative-ai-app-builder/docs/locations to use the correct regional API endpoint.
Root cause
In discovery_engine_search_tool.py (L75-84), the SearchServiceClient is always created with the default global endpoint (discoveryengine.googleapis.com):
credentials, _ = google.auth.default()
quota_project_id = getattr(credentials, "quota_project_id", None)
options = (
client_options.ClientOptions(quota_project_id=quota_project_id)
if quota_project_id
else None
)
self._discovery_engine_client = discoveryengine.SearchServiceClient(
credentials=credentials, client_options=options
)However, regional data stores (e.g. eu, us, or single-region like europe-west1) require regional endpoints such as eu-discoveryengine.googleapis.com, as documented in Discovery Engine locations.
The location is already present in the data_store_id parameter (e.g. projects/{project}/locations/eu/collections/…), but it is never used to configure the client endpoint.
Reproduction
from google.adk.tools import DiscoveryEngineSearchTool
tool = DiscoveryEngineSearchTool(
data_store_id="projects/my-project/locations/eu/collections/default_collection/dataStores/my-datastore",
)
# Calling the tool triggers a 400 error
result = tool.discovery_engine_search("test query")
# → {"status": "error", "error_message": "400 Incorrect API endpoint used..."}Expected behavior
The tool should extract the location from data_store_id (or search_engine_id) and set the appropriate api_endpoint in ClientOptions:
eu→eu-discoveryengine.googleapis.comus→us-discoveryengine.googleapis.comeurope-west1→europe-west1-discoveryengine.googleapis.comglobal→discoveryengine.googleapis.com(default, unchanged)
Suggested fix
Parse the location from the resource ID and pass api_endpoint to ClientOptions:
import re
location_match = re.search(r"/locations/([^/]+)/", data_store_id or search_engine_id)
location = location_match.group(1) if location_match else "global"
api_endpoint = (
f"{location}-discoveryengine.googleapis.com"
if location != "global"
else "discoveryengine.googleapis.com"
)
options = client_options.ClientOptions(
api_endpoint=api_endpoint,
quota_project_id=quota_project_id,
)Alternatively, accept an optional client_options or api_endpoint parameter in the constructor to let users override it.
Environment
google-adkversion: 1.25.1- Data store location: eu
- Python: 3.14
Activity
llalitkumarrr commentedon Mar 4, 2026
Hello @kaligautier ,
Have you had a chance to test your fix? If it works well for you, please feel free to raise a PR. We will gladly review it and get it merged if all checks pass.
fix: use regional endpoint for non-global Discovery Engine data stores
fix: use regional endpoint for non-global Discovery Engine data stores
kaligautier commentedon Mar 5, 2026
This europe-west1 → europe-west1-discoveryengine.googleapis.com is not necessary we can keep us eu and global
llalitkumarrr commentedon Mar 6, 2026
Hello @kaligautier ,
Thank you for your contribution, we will review this and if all checks pass it will be merged.
llalitkumarrr commentedon Mar 6, 2026
Hello @rohityan , could you please have look at this?
chc4abt commentedon Mar 12, 2026
Hi, I am also facing this issue when using VertexAISearchTool with bypass_multi_tools_limit being set to True: https://google.github.io/adk-docs/tools/limitations/#workaround-2-bypass_multi_tools_limit
When do we expect the issue to be solved?
xuanyang15 commentedon Mar 16, 2026
bypass_multi_tools_limit and DiscoveryEngineSearchTool were introduce as a workaround for the model's limitation that built-in tools cannot be used with other tools together. Since new Gemini models no longer have the limitation, could you please switch to use the built in VertexAiSearchTool?
chc4abt commentedon Mar 17, 2026
Since we are EU based the application need to follow GDPR and EU AI act. Gemini 3 and Gemini 3.1 is not available through location EU. So we would appreciate the workaround to be fixed to be compatible again with eu located DiscoveryEngineToolSearchTool and Gemini Enterprise application
fix: use regional endpoint for non-global Discovery Engine data stores
xuanyang15 commentedon Mar 23, 2026
Thanks for the information! #4720 is under review now.
fix(tools): support regional Discovery Engine endpoints
fix(tools): support regional Discovery Engine endpoints
fix(tools): support regional Discovery Engine endpoints