Skip to content

Bug: googleSearchRetrieval(true) causes INVALID_ARGUMENT error with Gemini 2.0 (use google_search instead) #2185

Closed
@drelum

Description

@drelum

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions