diff --git a/examples/src/main/java/com/google/genai/examples/ComputeTokens.java b/examples/src/main/java/com/google/genai/examples/ComputeTokens.java
new file mode 100644
index 00000000000..a5dc01ca984
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/ComputeTokens.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Usage:
+ *
+ * 1a. If you are using Vertex AI, setup ADC to get credentials:
+ * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp
+ *
+ *
Then set Project, Location, and USE_VERTEXAI flag as environment variables:
+ *
+ *
export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT
+ *
+ *
export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION
+ *
+ *
1b. If you are using Gemini Developer AI, set an API key environment variable. You can find a
+ * list of available API keys here: https://aistudio.google.com/app/apikey
+ *
+ *
export GOOGLE_API_KEY=YOUR_API_KEY
+ *
+ *
2. Compile the java package and run the sample code.
+ *
+ *
mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.CountTokens"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.types.ComputeTokensResponse;
+
+/** An example of using the Unified Gen AI Java SDK to compute tokens for simple text input. */
+public class ComputeTokens {
+ public static void main(String[] args) {
+ // Instantiate the client using Vertex AI.
+ Client client = Client.builder().vertexAI(true).build();
+
+ ComputeTokensResponse response =
+ client.models.computeTokens("gemini-2.0-flash-001", "What is your name?", null);
+
+ // Gets the text string from the response by the quick accessor method `text()`.
+ System.out.println("Unary response: " + response);
+ }
+}
diff --git a/examples/src/main/java/com/google/genai/examples/CountTokens.java b/examples/src/main/java/com/google/genai/examples/CountTokens.java
new file mode 100644
index 00000000000..dad964e9d3f
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/CountTokens.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Usage:
+ *
+ *
1a. If you are using Vertex AI, setup ADC to get credentials:
+ * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp
+ *
+ *
Then set Project, Location, and USE_VERTEXAI flag as environment variables:
+ *
+ *
export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT
+ *
+ *
export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION
+ *
+ *
1b. If you are using Gemini Developer AI, set an API key environment variable. You can find a
+ * list of available API keys here: https://aistudio.google.com/app/apikey
+ *
+ *
export GOOGLE_API_KEY=YOUR_API_KEY
+ *
+ *
2. Compile the java package and run the sample code.
+ *
+ *
mvn clean compile exec:java -Dexec.mainClass="com.google.genai.examples.CountTokens"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.types.CountTokensResponse;
+
+/** An example of using the Unified Gen AI Java SDK to count tokens for simple text input. */
+public class CountTokens {
+ public static void main(String[] args) {
+ // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API
+ // key from the environment variable `GOOGLE_API_KEY`.
+ Client client = new Client();
+
+ CountTokensResponse response =
+ client.models.countTokens("gemini-2.0-flash-001", "What is your name?", null);
+
+ // Gets the text string from the response by the quick accessor method `text()`.
+ System.out.println("Unary response: " + response);
+ }
+}
diff --git a/examples/src/main/java/com/google/genai/examples/CountTokensWithConfigs.java b/examples/src/main/java/com/google/genai/examples/CountTokensWithConfigs.java
new file mode 100644
index 00000000000..2c898e51820
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/CountTokensWithConfigs.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Usage:
+ *
+ *
1a. If you are using Vertex AI, setup ADC to get credentials:
+ * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp
+ *
+ *
Then set Project, Location, and USE_VERTEXAI flag as environment variables:
+ *
+ *
export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT
+ *
+ *
export GOOGLE_CLOUD_LOCATION=YOUR_LOCATION
+ *
+ *
1b. If you are using Gemini Developer AI, set an API key environment variable. You can find a
+ * list of available API keys here: https://aistudio.google.com/app/apikey
+ *
+ *
export GOOGLE_API_KEY=YOUR_API_KEY
+ *
+ *
2. Compile the java package and run the sample code.
+ *
+ *
mvn clean compile
+ *
+ *
mvn exec:java -Dexec.mainClass="com.google.genai.examples.CountTokensWithConfigs"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.types.Content;
+import com.google.genai.types.CountTokensConfig;
+import com.google.genai.types.CountTokensResponse;
+import com.google.genai.types.GoogleSearch;
+import com.google.genai.types.Part;
+import com.google.genai.types.SafetySetting;
+import com.google.genai.types.Tool;
+
+/** An example of using the Unified Gen AI Java SDK to generate content with extra configs. */
+public class CountTokensWithConfigs {
+ public static void main(String[] args) {
+ // Instantiate the client using Vertex AI.
+ Client client = Client.builder().vertexAI(true).build();
+
+ // Sets the system instruction in the config.
+ Content systemInstruction = Content.fromParts(Part.fromText("You are a history teacher."));
+
+ CountTokensConfig config =
+ CountTokensConfig.builder()
+ .systemInstruction(systemInstruction)
+ .build();
+
+ CountTokensResponse response =
+ client.models.countTokens("gemini-2.0-flash-001", "Tell me the history of LLM", config);
+
+ System.out.println("Response: " + response);
+ }
+}
diff --git a/examples/src/main/java/com/google/genai/examples/GenerateVideos.java b/examples/src/main/java/com/google/genai/examples/GenerateVideos.java
index 02d2689f47c..1bceaac111d 100644
--- a/examples/src/main/java/com/google/genai/examples/GenerateVideos.java
+++ b/examples/src/main/java/com/google/genai/examples/GenerateVideos.java
@@ -77,7 +77,7 @@ public static void main(String[] args) {
try {
Thread.sleep(10000); // Sleep for 10 seconds.
generateVideosOperation =
- client.operations.getVideoOperation(generateVideosOperation, null);
+ client.operations.getVideosOperation(generateVideosOperation, null);
System.out.println("Waiting for operation to complete...");
} catch (InterruptedException e) {
System.out.println("Thread was interrupted while sleeping.");
diff --git a/examples/src/main/java/com/google/genai/examples/GenerateVideosAsync.java b/examples/src/main/java/com/google/genai/examples/GenerateVideosAsync.java
index 50584d8e59e..fa053ed38fe 100644
--- a/examples/src/main/java/com/google/genai/examples/GenerateVideosAsync.java
+++ b/examples/src/main/java/com/google/genai/examples/GenerateVideosAsync.java
@@ -83,7 +83,7 @@ public static void main(String[] args) {
try {
Thread.sleep(10000); // Sleep for 10 seconds.
try {
- operation = client.async.operations.getVideoOperation(operation, null).get();
+ operation = client.async.operations.getVideosOperation(operation, null).get();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
diff --git a/pom.xml b/pom.xml
index c3a97977ef4..87db181a86d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.google.genai
google-genai
google-genai
- 0.6.1
+ 0.7.0
jar
Java idiomatic SDK for the Gemini Developer APIs and Vertex AI APIs.
diff --git a/src/main/java/com/google/genai/AsyncModels.java b/src/main/java/com/google/genai/AsyncModels.java
index 87acc460b3b..682d85a293d 100644
--- a/src/main/java/com/google/genai/AsyncModels.java
+++ b/src/main/java/com/google/genai/AsyncModels.java
@@ -18,7 +18,11 @@
package com.google.genai;
+import com.google.genai.types.ComputeTokensConfig;
+import com.google.genai.types.ComputeTokensResponse;
import com.google.genai.types.Content;
+import com.google.genai.types.CountTokensConfig;
+import com.google.genai.types.CountTokensResponse;
import com.google.genai.types.EditImageConfig;
import com.google.genai.types.EditImageResponse;
import com.google.genai.types.EmbedContentConfig;
@@ -36,6 +40,7 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
+/** Async module of {@link Models} */
public final class AsyncModels {
Models models;
@@ -43,6 +48,29 @@ public AsyncModels(ApiClient apiClient) {
this.models = new Models(apiClient);
}
+ public CompletableFuture countTokens(
+ String model, List contents, CountTokensConfig config) {
+ return CompletableFuture.supplyAsync(() -> models.countTokens(model, contents, config));
+ }
+
+ public CompletableFuture computeTokens(
+ String model, List contents, ComputeTokensConfig config) {
+ return CompletableFuture.supplyAsync(() -> models.computeTokens(model, contents, config));
+ }
+
+ /**
+ * Asynchronously generates videos given a GenAI model, and a prompt or an image.
+ *
+ * This method is experimental.
+ *
+ * @param model the name of the GenAI model to use for generating videos
+ * @param prompt the text prompt for generating the videos. Optional for image to video use cases.
+ * @param image the input image for generating the videos. Optional if prompt is provided.
+ * @param config a {@link com.google.genai.types.GenerateVideosConfig} instance that specifies the
+ * optional configurations
+ * @return a {@link com.google.genai.types.GenerateVideosOperation} instance that contains the
+ * generated videos.
+ */
public CompletableFuture generateVideos(
String model, String prompt, Image image, GenerateVideosConfig config) {
return CompletableFuture.supplyAsync(() -> models.generateVideos(model, prompt, image, config));
diff --git a/src/main/java/com/google/genai/AsyncOperations.java b/src/main/java/com/google/genai/AsyncOperations.java
index 39309dddbab..ba2710233b5 100644
--- a/src/main/java/com/google/genai/AsyncOperations.java
+++ b/src/main/java/com/google/genai/AsyncOperations.java
@@ -22,6 +22,7 @@
import com.google.genai.types.GetOperationConfig;
import java.util.concurrent.CompletableFuture;
+/** Async module of {@link Operations} */
public final class AsyncOperations {
Operations operations;
@@ -36,8 +37,8 @@ public AsyncOperations(ApiClient apiClient) {
* @param config The configuration for getting the operation.
* @return A GenerateVideosOperation with the updated status of the operation.
*/
- public CompletableFuture getVideoOperation(
+ public CompletableFuture getVideosOperation(
GenerateVideosOperation operation, GetOperationConfig config) {
- return CompletableFuture.supplyAsync(() -> operations.getVideoOperation(operation, config));
+ return CompletableFuture.supplyAsync(() -> operations.getVideosOperation(operation, config));
}
}
diff --git a/src/main/java/com/google/genai/HttpApiClient.java b/src/main/java/com/google/genai/HttpApiClient.java
index 3adc03cfeba..f1363f05650 100644
--- a/src/main/java/com/google/genai/HttpApiClient.java
+++ b/src/main/java/com/google/genai/HttpApiClient.java
@@ -16,6 +16,7 @@
package com.google.genai;
+import com.google.api.core.InternalApi;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.collect.ImmutableMap;
import com.google.genai.errors.GenAiIOException;
@@ -30,8 +31,9 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
-/** Base client for the HTTP APIs. */
-final class HttpApiClient extends ApiClient {
+/** Base client for the HTTP APIs. This is for internal use only. */
+@InternalApi
+public class HttpApiClient extends ApiClient {
/** Constructs an ApiClient for Google AI APIs. */
HttpApiClient(Optional apiKey, Optional httpOptions) {
@@ -49,7 +51,7 @@ final class HttpApiClient extends ApiClient {
/** Sends a Http request given the http method, path, and request json string. */
@Override
- public ApiResponse request(String httpMethod, String path, String requestJson) {
+ public HttpApiResponse request(String httpMethod, String path, String requestJson) {
boolean queryBaseModel =
httpMethod.equalsIgnoreCase("GET") && path.startsWith("publishers/google/models/");
if (this.vertexAI() && !path.startsWith("projects/") && !queryBaseModel) {
@@ -119,7 +121,7 @@ private void setHeaders(HttpRequestBase request) {
}
/** Executes the given HTTP request. */
- private ApiResponse executeRequest(HttpRequestBase request) {
+ private HttpApiResponse executeRequest(HttpRequestBase request) {
try {
return new HttpApiResponse(httpClient.execute(request));
} catch (IOException e) {
diff --git a/src/main/java/com/google/genai/LiveConverters.java b/src/main/java/com/google/genai/LiveConverters.java
index 852ed9f50c4..5cc4b268d86 100644
--- a/src/main/java/com/google/genai/LiveConverters.java
+++ b/src/main/java/com/google/genai/LiveConverters.java
@@ -309,6 +309,171 @@ ObjectNode googleSearchRetrievalToVertex(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode enterpriseWebSearchToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode enterpriseWebSearchToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode apiKeyConfigToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyString"}))) {
+ throw new IllegalArgumentException("apiKeyString parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode apiKeyConfigToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"apiKeyString"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"apiKeyString"},
+ Common.getValueByPath(fromObject, new String[] {"apiKeyString"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode authConfigToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}))) {
+ throw new IllegalArgumentException("apiKeyConfig parameter is not supported in Gemini API.");
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authType"},
+ Common.getValueByPath(fromObject, new String[] {"authType"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleServiceAccountConfig"},
+ Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"httpBasicAuthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oauthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oidcConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode authConfigToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"apiKeyConfig"},
+ apiKeyConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"})),
+ toObject));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authType"},
+ Common.getValueByPath(fromObject, new String[] {"authType"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleServiceAccountConfig"},
+ Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"httpBasicAuthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oauthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oidcConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode googleMapsToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authConfig"}))) {
+ throw new IllegalArgumentException("authConfig parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode googleMapsToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"authConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authConfig"},
+ authConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"authConfig"})),
+ toObject));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -338,6 +503,15 @@ ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode pare
toObject));
}
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}))) {
+ throw new IllegalArgumentException(
+ "enterpriseWebSearch parameter is not supported in Gemini API.");
+ }
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"googleMaps"}))) {
+ throw new IllegalArgumentException("googleMaps parameter is not supported in Gemini API.");
+ }
+
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
Common.setValueByPath(
toObject,
@@ -387,6 +561,28 @@ ObjectNode toolToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode par
toObject));
}
+ if (Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"enterpriseWebSearch"},
+ enterpriseWebSearchToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"})),
+ toObject));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleMaps"},
+ googleMapsToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
+ toObject));
+ }
+
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
Common.setValueByPath(
toObject,
@@ -775,10 +971,15 @@ ObjectNode liveConnectConfigToMldev(
Common.setValueByPath(parentObject, new String[] {"setup", "tools"}, result);
}
- if (!Common.isZero(
- Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}))) {
- throw new IllegalArgumentException(
- "inputAudioTranscription parameter is not supported in Gemini API.");
+ if (Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}) != null) {
+ Common.setValueByPath(
+ parentObject,
+ new String[] {"setup", "inputAudioTranscription"},
+ audioTranscriptionConfigToMldev(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
+ toObject));
}
if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
@@ -1180,10 +1381,15 @@ ObjectNode liveClientSetupToMldev(
toObject));
}
- if (!Common.isZero(
- Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}))) {
- throw new IllegalArgumentException(
- "inputAudioTranscription parameter is not supported in Gemini API.");
+ if (Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"inputAudioTranscription"},
+ audioTranscriptionConfigToMldev(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"inputAudioTranscription"})),
+ toObject));
}
if (Common.getValueByPath(fromObject, new String[] {"outputAudioTranscription"}) != null) {
diff --git a/src/main/java/com/google/genai/Models.java b/src/main/java/com/google/genai/Models.java
index 74fa50dfc70..9723360d544 100644
--- a/src/main/java/com/google/genai/Models.java
+++ b/src/main/java/com/google/genai/Models.java
@@ -24,7 +24,13 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableList;
import com.google.genai.errors.GenAiIOException;
+import com.google.genai.types.ComputeTokensConfig;
+import com.google.genai.types.ComputeTokensParameters;
+import com.google.genai.types.ComputeTokensResponse;
import com.google.genai.types.Content;
+import com.google.genai.types.CountTokensConfig;
+import com.google.genai.types.CountTokensParameters;
+import com.google.genai.types.CountTokensResponse;
import com.google.genai.types.EditImageConfig;
import com.google.genai.types.EditImageParameters;
import com.google.genai.types.EditImageResponse;
@@ -56,6 +62,11 @@
import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;
+/**
+ * Provides methods for interacting with the available GenAI models. Instantiating this class is not
+ * required. After instantiating a {@link Client}, access methods through
+ * `client.models.methodName(...)` directly.
+ */
public final class Models {
private final ApiClient apiClient;
@@ -239,6 +250,80 @@ ObjectNode googleSearchRetrievalToMldev(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode enterpriseWebSearchToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode apiKeyConfigToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyString"}))) {
+ throw new IllegalArgumentException("apiKeyString parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode authConfigToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}))) {
+ throw new IllegalArgumentException("apiKeyConfig parameter is not supported in Gemini API.");
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authType"},
+ Common.getValueByPath(fromObject, new String[] {"authType"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleServiceAccountConfig"},
+ Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"httpBasicAuthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oauthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oidcConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode googleMapsToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"authConfig"}))) {
+ throw new IllegalArgumentException("authConfig parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -268,6 +353,15 @@ ObjectNode toolToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode pare
toObject));
}
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}))) {
+ throw new IllegalArgumentException(
+ "enterpriseWebSearch parameter is not supported in Gemini API.");
+ }
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"googleMaps"}))) {
+ throw new IllegalArgumentException("googleMaps parameter is not supported in Gemini API.");
+ }
+
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
Common.setValueByPath(
toObject,
@@ -306,6 +400,31 @@ ObjectNode functionCallingConfigToMldev(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode latLngToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"latitude"}))) {
+ throw new IllegalArgumentException("latitude parameter is not supported in Gemini API.");
+ }
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"longitude"}))) {
+ throw new IllegalArgumentException("longitude parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode retrievalConfigToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"latLng"}))) {
+ throw new IllegalArgumentException("latLng parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode toolConfigToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -320,6 +439,11 @@ ObjectNode toolConfigToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNod
toObject));
}
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}))) {
+ throw new IllegalArgumentException(
+ "retrievalConfig parameter is not supported in Gemini API.");
+ }
+
return toObject;
}
@@ -864,6 +988,66 @@ ObjectNode generateImagesParametersToMldev(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensConfigToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))) {
+ throw new IllegalArgumentException(
+ "systemInstruction parameter is not supported in Gemini API.");
+ }
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"tools"}))) {
+ throw new IllegalArgumentException("tools parameter is not supported in Gemini API.");
+ }
+
+ if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"generationConfig"}))) {
+ throw new IllegalArgumentException(
+ "generationConfig parameter is not supported in Gemini API.");
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensParametersToMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"model"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"_url", "model"},
+ Transformers.tModel(
+ this.apiClient, Common.getValueByPath(fromObject, new String[] {"model"})));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"contents"}) != null) {
+ ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"contents"});
+ ObjectMapper objectMapper = new ObjectMapper();
+ ArrayNode result = objectMapper.createArrayNode();
+
+ keyArray.forEach(
+ item -> {
+ result.add(contentToMldev(apiClient, JsonSerializable.toJsonNode(item), toObject));
+ });
+ Common.setValueByPath(toObject, new String[] {"contents"}, result);
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"config"},
+ countTokensConfigToMldev(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"config"})),
+ toObject));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode imageToMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -1183,6 +1367,97 @@ ObjectNode googleSearchRetrievalToVertex(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode enterpriseWebSearchToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode apiKeyConfigToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"apiKeyString"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"apiKeyString"},
+ Common.getValueByPath(fromObject, new String[] {"apiKeyString"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode authConfigToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"apiKeyConfig"},
+ apiKeyConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"apiKeyConfig"})),
+ toObject));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"authType"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authType"},
+ Common.getValueByPath(fromObject, new String[] {"authType"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleServiceAccountConfig"},
+ Common.getValueByPath(fromObject, new String[] {"googleServiceAccountConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"httpBasicAuthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"httpBasicAuthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oauthConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oauthConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oauthConfig"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"oidcConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"oidcConfig"},
+ Common.getValueByPath(fromObject, new String[] {"oidcConfig"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode googleMapsToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"authConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"authConfig"},
+ authConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"authConfig"})),
+ toObject));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode toolToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -1215,6 +1490,28 @@ ObjectNode toolToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode par
toObject));
}
+ if (Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"enterpriseWebSearch"},
+ enterpriseWebSearchToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"enterpriseWebSearch"})),
+ toObject));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"googleMaps"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"googleMaps"},
+ googleMapsToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"googleMaps"})),
+ toObject));
+ }
+
if (Common.getValueByPath(fromObject, new String[] {"codeExecution"}) != null) {
Common.setValueByPath(
toObject,
@@ -1253,6 +1550,44 @@ ObjectNode functionCallingConfigToVertex(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode latLngToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"latitude"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"latitude"},
+ Common.getValueByPath(fromObject, new String[] {"latitude"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"longitude"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"longitude"},
+ Common.getValueByPath(fromObject, new String[] {"longitude"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode retrievalConfigToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"latLng"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"latLng"},
+ latLngToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"latLng"})),
+ toObject));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode toolConfigToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -1267,6 +1602,17 @@ ObjectNode toolConfigToVertex(ApiClient apiClient, JsonNode fromObject, ObjectNo
toObject));
}
+ if (Common.getValueByPath(fromObject, new String[] {"retrievalConfig"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"retrievalConfig"},
+ retrievalConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"retrievalConfig"})),
+ toObject));
+ }
+
return toObject;
}
@@ -2276,6 +2622,118 @@ ObjectNode upscaleImageAPIParametersToVertex(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensConfigToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+
+ if (Common.getValueByPath(fromObject, new String[] {"systemInstruction"}) != null) {
+ Common.setValueByPath(
+ parentObject,
+ new String[] {"systemInstruction"},
+ contentToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Transformers.tContent(
+ this.apiClient,
+ Common.getValueByPath(fromObject, new String[] {"systemInstruction"}))),
+ toObject));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"tools"}) != null) {
+ ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"tools"});
+ ObjectMapper objectMapper = new ObjectMapper();
+ ArrayNode result = objectMapper.createArrayNode();
+
+ keyArray.forEach(
+ item -> {
+ result.add(toolToVertex(apiClient, JsonSerializable.toJsonNode(item), toObject));
+ });
+ Common.setValueByPath(parentObject, new String[] {"tools"}, result);
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"generationConfig"}) != null) {
+ Common.setValueByPath(
+ parentObject,
+ new String[] {"generationConfig"},
+ Common.getValueByPath(fromObject, new String[] {"generationConfig"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensParametersToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"model"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"_url", "model"},
+ Transformers.tModel(
+ this.apiClient, Common.getValueByPath(fromObject, new String[] {"model"})));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"contents"}) != null) {
+ ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"contents"});
+ ObjectMapper objectMapper = new ObjectMapper();
+ ArrayNode result = objectMapper.createArrayNode();
+
+ keyArray.forEach(
+ item -> {
+ result.add(contentToVertex(apiClient, JsonSerializable.toJsonNode(item), toObject));
+ });
+ Common.setValueByPath(toObject, new String[] {"contents"}, result);
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"config"},
+ countTokensConfigToVertex(
+ apiClient,
+ JsonSerializable.toJsonNode(
+ Common.getValueByPath(fromObject, new String[] {"config"})),
+ toObject));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode computeTokensParametersToVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"model"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"_url", "model"},
+ Transformers.tModel(
+ this.apiClient, Common.getValueByPath(fromObject, new String[] {"model"})));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"contents"}) != null) {
+ ArrayNode keyArray = (ArrayNode) Common.getValueByPath(fromObject, new String[] {"contents"});
+ ObjectMapper objectMapper = new ObjectMapper();
+ ArrayNode result = objectMapper.createArrayNode();
+
+ keyArray.forEach(
+ item -> {
+ result.add(contentToVertex(apiClient, JsonSerializable.toJsonNode(item), toObject));
+ });
+ Common.setValueByPath(toObject, new String[] {"contents"}, result);
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"config"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"config"},
+ Common.getValueByPath(fromObject, new String[] {"config"}));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode generateVideosConfigToVertex(
ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
@@ -2809,6 +3267,27 @@ ObjectNode generateImagesResponseFromMldev(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensResponseFromMldev(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"totalTokens"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"totalTokens"},
+ Common.getValueByPath(fromObject, new String[] {"totalTokens"}));
+ }
+
+ if (Common.getValueByPath(fromObject, new String[] {"cachedContentTokenCount"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"cachedContentTokenCount"},
+ Common.getValueByPath(fromObject, new String[] {"cachedContentTokenCount"}));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode videoFromMldev(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -3450,6 +3929,34 @@ ObjectNode upscaleImageResponseFromVertex(
return toObject;
}
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode countTokensResponseFromVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"totalTokens"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"totalTokens"},
+ Common.getValueByPath(fromObject, new String[] {"totalTokens"}));
+ }
+
+ return toObject;
+ }
+
+ @ExcludeFromGeneratedCoverageReport
+ ObjectNode computeTokensResponseFromVertex(
+ ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
+ ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
+ if (Common.getValueByPath(fromObject, new String[] {"tokensInfo"}) != null) {
+ Common.setValueByPath(
+ toObject,
+ new String[] {"tokensInfo"},
+ Common.getValueByPath(fromObject, new String[] {"tokensInfo"}));
+ }
+
+ return toObject;
+ }
+
@ExcludeFromGeneratedCoverageReport
ObjectNode videoFromVertex(ApiClient apiClient, JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper.createObjectNode();
@@ -3887,6 +4394,122 @@ private UpscaleImageResponse privateUpscaleImage(
}
}
+ public CountTokensResponse countTokens(
+ String model, List contents, CountTokensConfig config) {
+
+ CountTokensParameters.Builder parameterBuilder = CountTokensParameters.builder();
+
+ if (!Common.isZero(model)) {
+ parameterBuilder.model(model);
+ }
+ if (!Common.isZero(contents)) {
+ parameterBuilder.contents(contents);
+ }
+ if (!Common.isZero(config)) {
+ parameterBuilder.config(config);
+ }
+ JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
+
+ ObjectNode body;
+ String path;
+ if (this.apiClient.vertexAI()) {
+ body = countTokensParametersToVertex(this.apiClient, parameterNode, null);
+ path = Common.formatMap("{model}:countTokens", body.get("_url"));
+ } else {
+ body = countTokensParametersToMldev(this.apiClient, parameterNode, null);
+ path = Common.formatMap("{model}:countTokens", body.get("_url"));
+ }
+ body.remove("_url");
+
+ // TODO: Handle "_query" in the body (for list support).
+
+ // TODO: Remove the hack that removes config.
+ body.remove("config");
+
+ try (ApiResponse response =
+ this.apiClient.request("post", path, JsonSerializable.toJsonString(body))) {
+ HttpEntity entity = response.getEntity();
+ String responseString;
+ try {
+ responseString = EntityUtils.toString(entity);
+ } catch (IOException e) {
+ throw new GenAiIOException("Failed to read HTTP response.", e);
+ }
+ JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
+ if (this.apiClient.vertexAI()) {
+ responseNode = countTokensResponseFromVertex(this.apiClient, responseNode, null);
+ } else {
+ responseNode = countTokensResponseFromMldev(this.apiClient, responseNode, null);
+ }
+ return JsonSerializable.fromJsonNode(responseNode, CountTokensResponse.class);
+ }
+ }
+
+ public ComputeTokensResponse computeTokens(
+ String model, List contents, ComputeTokensConfig config) {
+
+ ComputeTokensParameters.Builder parameterBuilder = ComputeTokensParameters.builder();
+
+ if (!Common.isZero(model)) {
+ parameterBuilder.model(model);
+ }
+ if (!Common.isZero(contents)) {
+ parameterBuilder.contents(contents);
+ }
+ if (!Common.isZero(config)) {
+ parameterBuilder.config(config);
+ }
+ JsonNode parameterNode = JsonSerializable.toJsonNode(parameterBuilder.build());
+
+ ObjectNode body;
+ String path;
+ if (this.apiClient.vertexAI()) {
+ body = computeTokensParametersToVertex(this.apiClient, parameterNode, null);
+ path = Common.formatMap("{model}:computeTokens", body.get("_url"));
+ } else {
+ throw new UnsupportedOperationException(
+ "This method is not supported by the Gemini Developer API.");
+ }
+ body.remove("_url");
+
+ // TODO: Handle "_query" in the body (for list support).
+
+ // TODO: Remove the hack that removes config.
+ body.remove("config");
+
+ try (ApiResponse response =
+ this.apiClient.request("post", path, JsonSerializable.toJsonString(body))) {
+ HttpEntity entity = response.getEntity();
+ String responseString;
+ try {
+ responseString = EntityUtils.toString(entity);
+ } catch (IOException e) {
+ throw new GenAiIOException("Failed to read HTTP response.", e);
+ }
+ JsonNode responseNode = JsonSerializable.stringToJsonNode(responseString);
+ if (this.apiClient.vertexAI()) {
+ responseNode = computeTokensResponseFromVertex(this.apiClient, responseNode, null);
+ } else {
+ throw new UnsupportedOperationException(
+ "This method is not supported by the Gemini Developer API.");
+ }
+ return JsonSerializable.fromJsonNode(responseNode, ComputeTokensResponse.class);
+ }
+ }
+
+ /**
+ * Generates videos given a GenAI model, and a prompt or an image.
+ *
+ * This method is experimental.
+ *
+ * @param model the name of the GenAI model to use for generating videos
+ * @param prompt the text prompt for generating the videos. Optional for image to video use cases.
+ * @param image the input image for generating the videos. Optional if prompt is provided.
+ * @param config a {@link com.google.genai.types.GenerateVideosConfig} instance that specifies the
+ * optional configurations
+ * @return a {@link com.google.genai.types.GenerateVideosOperation} instance that contains the
+ * generated videos.
+ */
public GenerateVideosOperation generateVideos(
String model, String prompt, Image image, GenerateVideosConfig config) {
@@ -4035,6 +4658,35 @@ public ResponseStream generateContentStream(
model, Transformers.tContents(this.apiClient, (Object) text), config);
}
+ /**
+ * Counts tokens given a GenAI model and a text string.
+ *
+ * @param model the name of the GenAI model to use.
+ * @param text the text string to send to count tokens for.
+ * @param config a {@link com.google.genai.types.CountTokensConfig} instance that specifies the
+ * optional configurations
+ * @return a {@link com.google.genai.types.CountTokensResponse} instance that contains tokens
+ * count.
+ */
+ public CountTokensResponse countTokens(String model, String text, CountTokensConfig config) {
+ return countTokens(model, Transformers.tContents(this.apiClient, (Object) text), config);
+ }
+
+ /**
+ * Computes tokens given a GenAI model and a text string.
+ *
+ * @param model the name of the GenAI model to use.
+ * @param text the text string to send to compute tokens for.
+ * @param config a {@link com.google.genai.types.ComputeTokensConfig} instance that specifies the
+ * optional configurations
+ * @return a {@link com.google.genai.types.ComputeTokensResponse} instance that contains tokens
+ * results.
+ */
+ public ComputeTokensResponse computeTokens(
+ String model, String text, ComputeTokensConfig config) {
+ return computeTokens(model, Transformers.tContents(this.apiClient, (Object) text), config);
+ }
+
/**
* Generates images given a GenAI model and a prompt.
*
diff --git a/src/main/java/com/google/genai/Operations.java b/src/main/java/com/google/genai/Operations.java
index 32aacdab812..9cdaef0ad04 100644
--- a/src/main/java/com/google/genai/Operations.java
+++ b/src/main/java/com/google/genai/Operations.java
@@ -32,6 +32,13 @@
import org.apache.http.HttpEntity;
import org.apache.http.util.EntityUtils;
+/**
+ * Provides methods for managing the long-running operations. Instantiating this class is not
+ * required. After instantiating a {@link Client}, access methods through
+ * `client.operations.methodName(...)` directly.
+ *
+ * This module is experimental.
+ */
public final class Operations {
private final ApiClient apiClient;
@@ -474,7 +481,7 @@ private GenerateVideosOperation privateFetchPredictVideosOperation(
* @param config The configuration for getting the operation.
* @return A GenerateVideosOperation with the updated status of the operation.
*/
- public GenerateVideosOperation getVideoOperation(
+ public GenerateVideosOperation getVideosOperation(
GenerateVideosOperation operation, GetOperationConfig config) {
if (!operation.name().isPresent()) {
diff --git a/src/main/java/com/google/genai/types/ApiKeyConfig.java b/src/main/java/com/google/genai/types/ApiKeyConfig.java
new file mode 100644
index 00000000000..e9e896607e2
--- /dev/null
+++ b/src/main/java/com/google/genai/types/ApiKeyConfig.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Config for authentication with API key. */
+@AutoValue
+@JsonDeserialize(builder = ApiKeyConfig.Builder.class)
+public abstract class ApiKeyConfig extends JsonSerializable {
+ /** The API key to be used in the request directly. */
+ @JsonProperty("apiKeyString")
+ public abstract Optional apiKeyString();
+
+ /** Instantiates a builder for ApiKeyConfig. */
+ public static Builder builder() {
+ return new AutoValue_ApiKeyConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for ApiKeyConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `ApiKeyConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_ApiKeyConfig.Builder();
+ }
+
+ @JsonProperty("apiKeyString")
+ public abstract Builder apiKeyString(String apiKeyString);
+
+ public abstract ApiKeyConfig build();
+ }
+
+ /** Deserializes a JSON string to a ApiKeyConfig object. */
+ public static ApiKeyConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, ApiKeyConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthConfig.java b/src/main/java/com/google/genai/types/AuthConfig.java
new file mode 100644
index 00000000000..9d3ec898152
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthConfig.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Auth configuration to run the extension. */
+@AutoValue
+@JsonDeserialize(builder = AuthConfig.Builder.class)
+public abstract class AuthConfig extends JsonSerializable {
+ /** Config for API key auth. */
+ @JsonProperty("apiKeyConfig")
+ public abstract Optional apiKeyConfig();
+
+ /** Type of auth scheme. */
+ @JsonProperty("authType")
+ public abstract Optional authType();
+
+ /** Config for Google Service Account auth. */
+ @JsonProperty("googleServiceAccountConfig")
+ public abstract Optional googleServiceAccountConfig();
+
+ /** Config for HTTP Basic auth. */
+ @JsonProperty("httpBasicAuthConfig")
+ public abstract Optional httpBasicAuthConfig();
+
+ /** Config for user oauth. */
+ @JsonProperty("oauthConfig")
+ public abstract Optional oauthConfig();
+
+ /** Config for user OIDC auth. */
+ @JsonProperty("oidcConfig")
+ public abstract Optional oidcConfig();
+
+ /** Instantiates a builder for AuthConfig. */
+ public static Builder builder() {
+ return new AutoValue_AuthConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for AuthConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `AuthConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_AuthConfig.Builder();
+ }
+
+ @JsonProperty("apiKeyConfig")
+ public abstract Builder apiKeyConfig(ApiKeyConfig apiKeyConfig);
+
+ @JsonProperty("authType")
+ public abstract Builder authType(String authType);
+
+ @JsonProperty("googleServiceAccountConfig")
+ public abstract Builder googleServiceAccountConfig(
+ AuthConfigGoogleServiceAccountConfig googleServiceAccountConfig);
+
+ @JsonProperty("httpBasicAuthConfig")
+ public abstract Builder httpBasicAuthConfig(AuthConfigHttpBasicAuthConfig httpBasicAuthConfig);
+
+ @JsonProperty("oauthConfig")
+ public abstract Builder oauthConfig(AuthConfigOauthConfig oauthConfig);
+
+ @JsonProperty("oidcConfig")
+ public abstract Builder oidcConfig(AuthConfigOidcConfig oidcConfig);
+
+ public abstract AuthConfig build();
+ }
+
+ /** Deserializes a JSON string to a AuthConfig object. */
+ public static AuthConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, AuthConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthConfigGoogleServiceAccountConfig.java b/src/main/java/com/google/genai/types/AuthConfigGoogleServiceAccountConfig.java
new file mode 100644
index 00000000000..2e11e2a7524
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthConfigGoogleServiceAccountConfig.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Config for Google Service Account Authentication. */
+@AutoValue
+@JsonDeserialize(builder = AuthConfigGoogleServiceAccountConfig.Builder.class)
+public abstract class AuthConfigGoogleServiceAccountConfig extends JsonSerializable {
+ /**
+ * Optional. The service account that the extension execution service runs as. - If the service
+ * account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to
+ * Vertex AI Extension Service Agent
+ * (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the
+ * specified service account. - If not specified, the Vertex AI Extension Service Agent will be
+ * used to execute the Extension.
+ */
+ @JsonProperty("serviceAccount")
+ public abstract Optional serviceAccount();
+
+ /** Instantiates a builder for AuthConfigGoogleServiceAccountConfig. */
+ public static Builder builder() {
+ return new AutoValue_AuthConfigGoogleServiceAccountConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for AuthConfigGoogleServiceAccountConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /**
+ * For internal usage. Please use `AuthConfigGoogleServiceAccountConfig.builder()` for
+ * instantiation.
+ */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_AuthConfigGoogleServiceAccountConfig.Builder();
+ }
+
+ @JsonProperty("serviceAccount")
+ public abstract Builder serviceAccount(String serviceAccount);
+
+ public abstract AuthConfigGoogleServiceAccountConfig build();
+ }
+
+ /** Deserializes a JSON string to a AuthConfigGoogleServiceAccountConfig object. */
+ public static AuthConfigGoogleServiceAccountConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, AuthConfigGoogleServiceAccountConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthConfigHttpBasicAuthConfig.java b/src/main/java/com/google/genai/types/AuthConfigHttpBasicAuthConfig.java
new file mode 100644
index 00000000000..9c9aafd90b6
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthConfigHttpBasicAuthConfig.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Config for HTTP Basic Authentication. */
+@AutoValue
+@JsonDeserialize(builder = AuthConfigHttpBasicAuthConfig.Builder.class)
+public abstract class AuthConfigHttpBasicAuthConfig extends JsonSerializable {
+ /**
+ * Required. The name of the SecretManager secret version resource storing the base64 encoded
+ * credentials. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If specified,
+ * the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service
+ * Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the
+ * specified resource.
+ */
+ @JsonProperty("credentialSecret")
+ public abstract Optional credentialSecret();
+
+ /** Instantiates a builder for AuthConfigHttpBasicAuthConfig. */
+ public static Builder builder() {
+ return new AutoValue_AuthConfigHttpBasicAuthConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for AuthConfigHttpBasicAuthConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /**
+ * For internal usage. Please use `AuthConfigHttpBasicAuthConfig.builder()` for instantiation.
+ */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_AuthConfigHttpBasicAuthConfig.Builder();
+ }
+
+ @JsonProperty("credentialSecret")
+ public abstract Builder credentialSecret(String credentialSecret);
+
+ public abstract AuthConfigHttpBasicAuthConfig build();
+ }
+
+ /** Deserializes a JSON string to a AuthConfigHttpBasicAuthConfig object. */
+ public static AuthConfigHttpBasicAuthConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, AuthConfigHttpBasicAuthConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthConfigOauthConfig.java b/src/main/java/com/google/genai/types/AuthConfigOauthConfig.java
new file mode 100644
index 00000000000..7528e17562f
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthConfigOauthConfig.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Config for user oauth. */
+@AutoValue
+@JsonDeserialize(builder = AuthConfigOauthConfig.Builder.class)
+public abstract class AuthConfigOauthConfig extends JsonSerializable {
+ /**
+ * Access token for extension endpoint. Only used to propagate token from
+ * [[ExecuteExtensionRequest.runtime_auth_config]] at request time.
+ */
+ @JsonProperty("accessToken")
+ public abstract Optional accessToken();
+
+ /**
+ * The service account used to generate access tokens for executing the Extension. - If the
+ * service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be
+ * granted to Vertex AI Extension Service Agent
+ * (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided
+ * service account.
+ */
+ @JsonProperty("serviceAccount")
+ public abstract Optional serviceAccount();
+
+ /** Instantiates a builder for AuthConfigOauthConfig. */
+ public static Builder builder() {
+ return new AutoValue_AuthConfigOauthConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for AuthConfigOauthConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `AuthConfigOauthConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_AuthConfigOauthConfig.Builder();
+ }
+
+ @JsonProperty("accessToken")
+ public abstract Builder accessToken(String accessToken);
+
+ @JsonProperty("serviceAccount")
+ public abstract Builder serviceAccount(String serviceAccount);
+
+ public abstract AuthConfigOauthConfig build();
+ }
+
+ /** Deserializes a JSON string to a AuthConfigOauthConfig object. */
+ public static AuthConfigOauthConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, AuthConfigOauthConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthConfigOidcConfig.java b/src/main/java/com/google/genai/types/AuthConfigOidcConfig.java
new file mode 100644
index 00000000000..9e7b45f9fc3
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthConfigOidcConfig.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Config for user OIDC auth. */
+@AutoValue
+@JsonDeserialize(builder = AuthConfigOidcConfig.Builder.class)
+public abstract class AuthConfigOidcConfig extends JsonSerializable {
+ /**
+ * OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from
+ * [[ExecuteExtensionRequest.runtime_auth_config]] at request time.
+ */
+ @JsonProperty("idToken")
+ public abstract Optional idToken();
+
+ /**
+ * The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by
+ * the Google OIDC Provider (accounts.google.com) for extension endpoint
+ * (https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc).
+ * - The audience for the token will be set to the URL in the server url defined in the OpenApi
+ * spec. - If the service account is provided, the service account should grant
+ * `iam.serviceAccounts.getOpenIdToken` permission to Vertex AI Extension Service Agent
+ * (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents).
+ */
+ @JsonProperty("serviceAccount")
+ public abstract Optional serviceAccount();
+
+ /** Instantiates a builder for AuthConfigOidcConfig. */
+ public static Builder builder() {
+ return new AutoValue_AuthConfigOidcConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for AuthConfigOidcConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `AuthConfigOidcConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_AuthConfigOidcConfig.Builder();
+ }
+
+ @JsonProperty("idToken")
+ public abstract Builder idToken(String idToken);
+
+ @JsonProperty("serviceAccount")
+ public abstract Builder serviceAccount(String serviceAccount);
+
+ public abstract AuthConfigOidcConfig build();
+ }
+
+ /** Deserializes a JSON string to a AuthConfigOidcConfig object. */
+ public static AuthConfigOidcConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, AuthConfigOidcConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/AuthType.java b/src/main/java/com/google/genai/types/AuthType.java
new file mode 100644
index 00000000000..d5d16b52ebd
--- /dev/null
+++ b/src/main/java/com/google/genai/types/AuthType.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/** Type of auth scheme. */
+public class AuthType {
+
+ /** Enum representing the known values for AuthType. */
+ public enum Known {
+ AUTH_TYPE_UNSPECIFIED,
+ NO_AUTH,
+ API_KEY_AUTH,
+ HTTP_BASIC_AUTH,
+ GOOGLE_SERVICE_ACCOUNT_AUTH,
+ OAUTH,
+ OIDC_AUTH
+ }
+
+ private Known authTypeEnum;
+ private final String value;
+
+ @JsonCreator
+ public AuthType(String value) {
+ this.value = value;
+ for (Known authTypeEnum : Known.values()) {
+ if (authTypeEnum.toString().equalsIgnoreCase(value)) {
+ this.authTypeEnum = authTypeEnum;
+ break;
+ }
+ }
+ if (this.authTypeEnum == null) {
+ this.authTypeEnum = Known.AUTH_TYPE_UNSPECIFIED;
+ }
+ }
+
+ public AuthType(Known knownValue) {
+ this.authTypeEnum = knownValue;
+ this.value = knownValue.toString();
+ }
+
+ @Override
+ @JsonValue
+ public String toString() {
+ return this.value;
+ }
+
+ public Known knownEnum() {
+ return this.authTypeEnum;
+ }
+}
diff --git a/src/main/java/com/google/genai/types/ComputeTokensConfig.java b/src/main/java/com/google/genai/types/ComputeTokensConfig.java
new file mode 100644
index 00000000000..8f9aebf57f6
--- /dev/null
+++ b/src/main/java/com/google/genai/types/ComputeTokensConfig.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+
+/** Optional parameters for computing tokens. */
+@AutoValue
+@JsonDeserialize(builder = ComputeTokensConfig.Builder.class)
+public abstract class ComputeTokensConfig extends JsonSerializable {
+ /** Instantiates a builder for ComputeTokensConfig. */
+ public static Builder builder() {
+ return new AutoValue_ComputeTokensConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for ComputeTokensConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `ComputeTokensConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_ComputeTokensConfig.Builder();
+ }
+
+ public abstract ComputeTokensConfig build();
+ }
+
+ /** Deserializes a JSON string to a ComputeTokensConfig object. */
+ public static ComputeTokensConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, ComputeTokensConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/ComputeTokensParameters.java b/src/main/java/com/google/genai/types/ComputeTokensParameters.java
new file mode 100644
index 00000000000..515b484237b
--- /dev/null
+++ b/src/main/java/com/google/genai/types/ComputeTokensParameters.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.List;
+import java.util.Optional;
+
+/** Parameters for computing tokens. */
+@AutoValue
+@JsonDeserialize(builder = ComputeTokensParameters.Builder.class)
+public abstract class ComputeTokensParameters extends JsonSerializable {
+ /**
+ * ID of the model to use. For a list of models, see `Google models
+ * `_.
+ */
+ @JsonProperty("model")
+ public abstract Optional model();
+
+ /** Input content. */
+ @JsonProperty("contents")
+ public abstract Optional> contents();
+
+ /** Optional parameters for the request. */
+ @JsonProperty("config")
+ public abstract Optional config();
+
+ /** Instantiates a builder for ComputeTokensParameters. */
+ public static Builder builder() {
+ return new AutoValue_ComputeTokensParameters.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for ComputeTokensParameters. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `ComputeTokensParameters.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_ComputeTokensParameters.Builder();
+ }
+
+ @JsonProperty("model")
+ public abstract Builder model(String model);
+
+ @JsonProperty("contents")
+ public abstract Builder contents(List contents);
+
+ @JsonProperty("config")
+ public abstract Builder config(ComputeTokensConfig config);
+
+ public abstract ComputeTokensParameters build();
+ }
+
+ /** Deserializes a JSON string to a ComputeTokensParameters object. */
+ public static ComputeTokensParameters fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, ComputeTokensParameters.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/ComputeTokensResponse.java b/src/main/java/com/google/genai/types/ComputeTokensResponse.java
new file mode 100644
index 00000000000..a30887a013b
--- /dev/null
+++ b/src/main/java/com/google/genai/types/ComputeTokensResponse.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.List;
+import java.util.Optional;
+
+/** Response for computing tokens. */
+@AutoValue
+@JsonDeserialize(builder = ComputeTokensResponse.Builder.class)
+public abstract class ComputeTokensResponse extends JsonSerializable {
+ /**
+ * Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with
+ * a prompt in each instance. We also need to return lists of tokens info for the request with
+ * multiple instances.
+ */
+ @JsonProperty("tokensInfo")
+ public abstract Optional> tokensInfo();
+
+ /** Instantiates a builder for ComputeTokensResponse. */
+ public static Builder builder() {
+ return new AutoValue_ComputeTokensResponse.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for ComputeTokensResponse. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `ComputeTokensResponse.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_ComputeTokensResponse.Builder();
+ }
+
+ @JsonProperty("tokensInfo")
+ public abstract Builder tokensInfo(List tokensInfo);
+
+ public abstract ComputeTokensResponse build();
+ }
+
+ /** Deserializes a JSON string to a ComputeTokensResponse object. */
+ public static ComputeTokensResponse fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, ComputeTokensResponse.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/CountTokensConfig.java b/src/main/java/com/google/genai/types/CountTokensConfig.java
new file mode 100644
index 00000000000..671780f25d2
--- /dev/null
+++ b/src/main/java/com/google/genai/types/CountTokensConfig.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.List;
+import java.util.Optional;
+
+/** Config for the count_tokens method. */
+@AutoValue
+@JsonDeserialize(builder = CountTokensConfig.Builder.class)
+public abstract class CountTokensConfig extends JsonSerializable {
+ /** Instructions for the model to steer it toward better performance. */
+ @JsonProperty("systemInstruction")
+ public abstract Optional systemInstruction();
+
+ /**
+ * Code that enables the system to interact with external systems to perform an action outside of
+ * the knowledge and scope of the model.
+ */
+ @JsonProperty("tools")
+ public abstract Optional> tools();
+
+ /**
+ * Configuration that the model uses to generate the response. Not supported by the Gemini
+ * Developer API.
+ */
+ @JsonProperty("generationConfig")
+ public abstract Optional generationConfig();
+
+ /** Instantiates a builder for CountTokensConfig. */
+ public static Builder builder() {
+ return new AutoValue_CountTokensConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for CountTokensConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `CountTokensConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_CountTokensConfig.Builder();
+ }
+
+ @JsonProperty("systemInstruction")
+ public abstract Builder systemInstruction(Content systemInstruction);
+
+ @JsonProperty("tools")
+ public abstract Builder tools(List tools);
+
+ @JsonProperty("generationConfig")
+ public abstract Builder generationConfig(GenerationConfig generationConfig);
+
+ public abstract CountTokensConfig build();
+ }
+
+ /** Deserializes a JSON string to a CountTokensConfig object. */
+ public static CountTokensConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, CountTokensConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/CountTokensParameters.java b/src/main/java/com/google/genai/types/CountTokensParameters.java
new file mode 100644
index 00000000000..f964fd3bd1e
--- /dev/null
+++ b/src/main/java/com/google/genai/types/CountTokensParameters.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.List;
+import java.util.Optional;
+
+/** Parameters for counting tokens. */
+@AutoValue
+@JsonDeserialize(builder = CountTokensParameters.Builder.class)
+public abstract class CountTokensParameters extends JsonSerializable {
+ /**
+ * ID of the model to use. For a list of models, see `Google models
+ * `_.
+ */
+ @JsonProperty("model")
+ public abstract Optional model();
+
+ /** Input content. */
+ @JsonProperty("contents")
+ public abstract Optional> contents();
+
+ /** Configuration for counting tokens. */
+ @JsonProperty("config")
+ public abstract Optional config();
+
+ /** Instantiates a builder for CountTokensParameters. */
+ public static Builder builder() {
+ return new AutoValue_CountTokensParameters.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for CountTokensParameters. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `CountTokensParameters.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_CountTokensParameters.Builder();
+ }
+
+ @JsonProperty("model")
+ public abstract Builder model(String model);
+
+ @JsonProperty("contents")
+ public abstract Builder contents(List contents);
+
+ @JsonProperty("config")
+ public abstract Builder config(CountTokensConfig config);
+
+ public abstract CountTokensParameters build();
+ }
+
+ /** Deserializes a JSON string to a CountTokensParameters object. */
+ public static CountTokensParameters fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, CountTokensParameters.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/CountTokensResponse.java b/src/main/java/com/google/genai/types/CountTokensResponse.java
new file mode 100644
index 00000000000..7d965a37b87
--- /dev/null
+++ b/src/main/java/com/google/genai/types/CountTokensResponse.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Response for counting tokens. */
+@AutoValue
+@JsonDeserialize(builder = CountTokensResponse.Builder.class)
+public abstract class CountTokensResponse extends JsonSerializable {
+ /** Total number of tokens. */
+ @JsonProperty("totalTokens")
+ public abstract Optional totalTokens();
+
+ /** Number of tokens in the cached part of the prompt (the cached content). */
+ @JsonProperty("cachedContentTokenCount")
+ public abstract Optional cachedContentTokenCount();
+
+ /** Instantiates a builder for CountTokensResponse. */
+ public static Builder builder() {
+ return new AutoValue_CountTokensResponse.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for CountTokensResponse. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `CountTokensResponse.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_CountTokensResponse.Builder();
+ }
+
+ @JsonProperty("totalTokens")
+ public abstract Builder totalTokens(Integer totalTokens);
+
+ @JsonProperty("cachedContentTokenCount")
+ public abstract Builder cachedContentTokenCount(Integer cachedContentTokenCount);
+
+ public abstract CountTokensResponse build();
+ }
+
+ /** Deserializes a JSON string to a CountTokensResponse object. */
+ public static CountTokensResponse fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, CountTokensResponse.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/EnterpriseWebSearch.java b/src/main/java/com/google/genai/types/EnterpriseWebSearch.java
new file mode 100644
index 00000000000..29543cfc27f
--- /dev/null
+++ b/src/main/java/com/google/genai/types/EnterpriseWebSearch.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+
+/** Tool to search public web data, powered by Vertex AI Search and Sec4 compliance. */
+@AutoValue
+@JsonDeserialize(builder = EnterpriseWebSearch.Builder.class)
+public abstract class EnterpriseWebSearch extends JsonSerializable {
+ /** Instantiates a builder for EnterpriseWebSearch. */
+ public static Builder builder() {
+ return new AutoValue_EnterpriseWebSearch.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for EnterpriseWebSearch. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `EnterpriseWebSearch.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_EnterpriseWebSearch.Builder();
+ }
+
+ public abstract EnterpriseWebSearch build();
+ }
+
+ /** Deserializes a JSON string to a EnterpriseWebSearch object. */
+ public static EnterpriseWebSearch fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, EnterpriseWebSearch.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/GoogleMaps.java b/src/main/java/com/google/genai/types/GoogleMaps.java
new file mode 100644
index 00000000000..8159cc68147
--- /dev/null
+++ b/src/main/java/com/google/genai/types/GoogleMaps.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Tool to support Google Maps in Model. */
+@AutoValue
+@JsonDeserialize(builder = GoogleMaps.Builder.class)
+public abstract class GoogleMaps extends JsonSerializable {
+ /** Optional. Auth config for the Google Maps tool. */
+ @JsonProperty("authConfig")
+ public abstract Optional authConfig();
+
+ /** Instantiates a builder for GoogleMaps. */
+ public static Builder builder() {
+ return new AutoValue_GoogleMaps.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for GoogleMaps. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `GoogleMaps.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_GoogleMaps.Builder();
+ }
+
+ @JsonProperty("authConfig")
+ public abstract Builder authConfig(AuthConfig authConfig);
+
+ public abstract GoogleMaps build();
+ }
+
+ /** Deserializes a JSON string to a GoogleMaps object. */
+ public static GoogleMaps fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, GoogleMaps.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/LatLng.java b/src/main/java/com/google/genai/types/LatLng.java
new file mode 100644
index 00000000000..614d44d576e
--- /dev/null
+++ b/src/main/java/com/google/genai/types/LatLng.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/**
+ * An object that represents a latitude/longitude pair.
+ *
+ * This is expressed as a pair of doubles to represent degrees latitude and degrees longitude.
+ * Unless specified otherwise, this object must conform to the WGS84 standard.
+ * Values must be within normalized ranges.
+ */
+@AutoValue
+@JsonDeserialize(builder = LatLng.Builder.class)
+public abstract class LatLng extends JsonSerializable {
+ /** The latitude in degrees. It must be in the range [-90.0, +90.0]. */
+ @JsonProperty("latitude")
+ public abstract Optional latitude();
+
+ /** The longitude in degrees. It must be in the range [-180.0, +180.0] */
+ @JsonProperty("longitude")
+ public abstract Optional longitude();
+
+ /** Instantiates a builder for LatLng. */
+ public static Builder builder() {
+ return new AutoValue_LatLng.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for LatLng. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `LatLng.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_LatLng.Builder();
+ }
+
+ @JsonProperty("latitude")
+ public abstract Builder latitude(Double latitude);
+
+ @JsonProperty("longitude")
+ public abstract Builder longitude(Double longitude);
+
+ public abstract LatLng build();
+ }
+
+ /** Deserializes a JSON string to a LatLng object. */
+ public static LatLng fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, LatLng.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/RetrievalConfig.java b/src/main/java/com/google/genai/types/RetrievalConfig.java
new file mode 100644
index 00000000000..1cf3748af50
--- /dev/null
+++ b/src/main/java/com/google/genai/types/RetrievalConfig.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.Optional;
+
+/** Retrieval config. */
+@AutoValue
+@JsonDeserialize(builder = RetrievalConfig.Builder.class)
+public abstract class RetrievalConfig extends JsonSerializable {
+ /** Optional. The location of the user. */
+ @JsonProperty("latLng")
+ public abstract Optional latLng();
+
+ /** Instantiates a builder for RetrievalConfig. */
+ public static Builder builder() {
+ return new AutoValue_RetrievalConfig.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for RetrievalConfig. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `RetrievalConfig.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_RetrievalConfig.Builder();
+ }
+
+ @JsonProperty("latLng")
+ public abstract Builder latLng(LatLng latLng);
+
+ public abstract RetrievalConfig build();
+ }
+
+ /** Deserializes a JSON string to a RetrievalConfig object. */
+ public static RetrievalConfig fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, RetrievalConfig.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/TokensInfo.java b/src/main/java/com/google/genai/types/TokensInfo.java
new file mode 100644
index 00000000000..645611f4e9f
--- /dev/null
+++ b/src/main/java/com/google/genai/types/TokensInfo.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2025 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Auto-generated code. Do not edit.
+
+package com.google.genai.types;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.google.auto.value.AutoValue;
+import com.google.genai.JsonSerializable;
+import java.util.List;
+import java.util.Optional;
+
+/** Tokens info with a list of tokens and the corresponding list of token ids. */
+@AutoValue
+@JsonDeserialize(builder = TokensInfo.Builder.class)
+public abstract class TokensInfo extends JsonSerializable {
+ /** Optional. Optional fields for the role from the corresponding Content. */
+ @JsonProperty("role")
+ public abstract Optional role();
+
+ /** A list of token ids from the input. */
+ @JsonProperty("tokenIds")
+ public abstract Optional> tokenIds();
+
+ /** A list of tokens from the input. */
+ @JsonProperty("tokens")
+ public abstract Optional> tokens();
+
+ /** Instantiates a builder for TokensInfo. */
+ public static Builder builder() {
+ return new AutoValue_TokensInfo.Builder();
+ }
+
+ /** Creates a builder with the same values as this instance. */
+ public abstract Builder toBuilder();
+
+ /** Builder for TokensInfo. */
+ @AutoValue.Builder
+ public abstract static class Builder {
+ /** For internal usage. Please use `TokensInfo.builder()` for instantiation. */
+ @JsonCreator
+ private static Builder create() {
+ return new AutoValue_TokensInfo.Builder();
+ }
+
+ @JsonProperty("role")
+ public abstract Builder role(String role);
+
+ @JsonProperty("tokenIds")
+ public abstract Builder tokenIds(List tokenIds);
+
+ @JsonProperty("tokens")
+ public abstract Builder tokens(List tokens);
+
+ public abstract TokensInfo build();
+ }
+
+ /** Deserializes a JSON string to a TokensInfo object. */
+ public static TokensInfo fromJson(String jsonString) {
+ return JsonSerializable.fromJsonString(jsonString, TokensInfo.class);
+ }
+}
diff --git a/src/main/java/com/google/genai/types/Tool.java b/src/main/java/com/google/genai/types/Tool.java
index b135e4663b5..bbc13c08d3c 100644
--- a/src/main/java/com/google/genai/types/Tool.java
+++ b/src/main/java/com/google/genai/types/Tool.java
@@ -51,6 +51,17 @@ public abstract class Tool extends JsonSerializable {
@JsonProperty("googleSearchRetrieval")
public abstract Optional googleSearchRetrieval();
+ /**
+ * Optional. Enterprise web search tool type. Specialized retrieval tool that is powered by Vertex
+ * AI Search and Sec4 compliance.
+ */
+ @JsonProperty("enterpriseWebSearch")
+ public abstract Optional enterpriseWebSearch();
+
+ /** Optional. Google Maps tool type. Specialized retrieval tool that is powered by Google Maps. */
+ @JsonProperty("googleMaps")
+ public abstract Optional googleMaps();
+
/**
* Optional. CodeExecution tool type. Enables the model to execute code as part of generation.
* This field is only used by the Gemini Developer API services.
@@ -94,6 +105,12 @@ private static Builder create() {
@JsonProperty("googleSearchRetrieval")
public abstract Builder googleSearchRetrieval(GoogleSearchRetrieval googleSearchRetrieval);
+ @JsonProperty("enterpriseWebSearch")
+ public abstract Builder enterpriseWebSearch(EnterpriseWebSearch enterpriseWebSearch);
+
+ @JsonProperty("googleMaps")
+ public abstract Builder googleMaps(GoogleMaps googleMaps);
+
@JsonProperty("codeExecution")
public abstract Builder codeExecution(ToolCodeExecution codeExecution);
diff --git a/src/main/java/com/google/genai/types/ToolConfig.java b/src/main/java/com/google/genai/types/ToolConfig.java
index e2ffb39201e..007c5a0c0fa 100644
--- a/src/main/java/com/google/genai/types/ToolConfig.java
+++ b/src/main/java/com/google/genai/types/ToolConfig.java
@@ -37,6 +37,10 @@ public abstract class ToolConfig extends JsonSerializable {
@JsonProperty("functionCallingConfig")
public abstract Optional functionCallingConfig();
+ /** Optional. Retrieval config. */
+ @JsonProperty("retrievalConfig")
+ public abstract Optional retrievalConfig();
+
/** Instantiates a builder for ToolConfig. */
public static Builder builder() {
return new AutoValue_ToolConfig.Builder();
@@ -57,6 +61,9 @@ private static Builder create() {
@JsonProperty("functionCallingConfig")
public abstract Builder functionCallingConfig(FunctionCallingConfig functionCallingConfig);
+ @JsonProperty("retrievalConfig")
+ public abstract Builder retrievalConfig(RetrievalConfig retrievalConfig);
+
public abstract ToolConfig build();
}