Description
When using the VertexAiGeminiChatOptions class with the googleSearchRetrieval(true) option, the API call fails with the following error:
Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Unable to submit request because Please use google_search field instead of google_search_retrieval field.. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini
It seems that the Gemini 2.0 models have changed the way they handle tool calls for search retrieval, requiring google_search instead of google_search_retrieval.
Environment:
Spring AI version: 1.0.0-SNAPSHOT
Java version: Openjdk 23
Steps to reproduce:
Use VertexAiGeminiChatOptions with googleSearchRetrieval(true).
Attempt to make a request to the Gemini API.
The request fails with the INVALID_ARGUMENT error.
Expected behavior
The request should successfully execute the search retrieval using the correct parameter expected by Gemini 2.0.
Minimal Complete Reproducible example:
ChatOptions chatOptions = VertexAiGeminiChatOptions.builder()
.temperature(0.4)
.googleSearchRetrieval(true)
.build();