Skip to content

[vertexai] Unable to generate content with gemini-2.0-flash-001 model and grounding #11470

Description

@mrdziuban

Environment details

  1. Specify the API at the beginning of the title. For example, "[vision]: ...").
    General, Core, and Other are also allowed as types
  2. OS type and version: macOS 14.5
  3. Java version: 21
  4. Version(s): 1.19.0

Steps to reproduce

  1. Pass gemini-2.0-flash-001 as the value to GenerativeModel#setModelName
  2. Add a Tool using GoogleSearchRetrieval
  3. Submit a generateContent request

Code example

import com.google.cloud.vertexai.VertexAI;
import com.google.cloud.vertexai.generativeai.GenerativeModel;
import com.google.cloud.vertexai.api.GenerateContentResponse;
import com.google.cloud.vertexai.api.GoogleSearchRetrieval
import com.google.cloud.vertexai.api.Tool

try (VertexAI vertexAi = new VertexAI(PROJECT_ID, LOCATION)) {
  Tool tool = Tool.newBuilder.setGoogleSearchRetrieval(GoogleSearchRetrieval.newBuilder()).build();

  GenerativeModel model = new GenerativeModel.Builder()
    .setModelName("gemini-2.0-flash-001")
    .setVertexAi(vertexAi)
    .setTools(Arrays.asList(tool));

  GenerateContentResponse response = model.generateContent("test");
}

Stack trace

The error response I get is

{
  "error": {
    "code": 400,
    "message": "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",
    "errors": [
      {
        "message": "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",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Any additional information below

It looks like the google-cloud-aiplatform project has been updated to support google_search in addition to google_search_retrieval -- could the google-cloud-vertexai project do the same?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: vertex-aiIssues related to the Vertex AI API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions