diff --git a/examples/pom.xml b/examples/pom.xml
index f882f1bd03f..6ba67e71f38 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -80,4 +80,27 @@
2.0.17
+
+
+ google3-local
+
+
+ ${project.basedir}/../src/main/java/com/google/genai/interactions/core/http/HttpClient.kt
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ com/google/genai/examples/Interaction*
+
+
+
+
+
+
+
diff --git a/examples/resources/sample_audio.mp3 b/examples/resources/sample_audio.mp3
new file mode 100644
index 00000000000..68a00666d3f
Binary files /dev/null and b/examples/resources/sample_audio.mp3 differ
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionBasic.java b/examples/src/main/java/com/google/genai/examples/InteractionBasic.java
new file mode 100644
index 00000000000..91f35a10609
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionBasic.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionBasic"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to create a basic interaction. */
+public final class InteractionBasic {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Why is the sky blue?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionBasic() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreate.java b/examples/src/main/java/com/google/genai/examples/InteractionCreate.java
new file mode 100644
index 00000000000..fe420b7944e
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionCreate.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionCreate"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to create an interaction. */
+public final class InteractionCreate {
+ 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`. Vertex AI API can be used by setting the
+ // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting
+ // `GOOGLE_GENAI_USE_VERTEXAI` to "true".
+ //
+ // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will
+ // get a `UnsupportedOperationException` if you try to use a service that is not available in
+ // the backend you are using.
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Using Vertex AI");
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What is your name?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionCreate() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java
new file mode 100644
index 00000000000..fd296d9eab8
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsync.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionCreateAsync"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.concurrent.CompletableFuture;
+
+/** An example of using the Unified Gen AI Java SDK to create an interaction asynchronously. */
+public final class InteractionCreateAsync {
+ 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`. Vertex AI API can be used by setting the
+ // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting
+ // `GOOGLE_GENAI_USE_VERTEXAI` to "true".
+ //
+ // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will
+ // get a `UnsupportedOperationException` if you try to use a service that is not available in
+ // the backend you are using.
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Using Vertex AI");
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What is your name?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .build();
+
+ CompletableFuture interactionFuture =
+ client.async.interactions.create(CreateInteractionRequestBody.of(params))
+ .body()
+ .thenApply(
+ response ->
+ response
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction")));
+
+ interactionFuture
+ .thenAccept(
+ interaction -> {
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ })
+ .join();
+ }
+
+ private InteractionCreateAsync() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java
new file mode 100644
index 00000000000..d0381471a1b
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateAsyncStreaming.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionCreateAsyncStreaming"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
+import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.StepDelta;
+import com.google.genai.gaos.models.interactions.StepDeltaData;
+import com.google.genai.gaos.models.interactions.TextDelta;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.concurrent.CompletableFuture;
+import org.reactivestreams.Subscriber;
+import org.reactivestreams.Subscription;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create a streaming interaction asynchronously.
+ */
+public final class InteractionCreateAsyncStreaming {
+ 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`. Vertex AI API can be used by setting the
+ // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting
+ // `GOOGLE_GENAI_USE_VERTEXAI` to "true".
+ //
+ // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will
+ // get a `UnsupportedOperationException` if you try to use a service that is not available in
+ // the backend you are using.
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Using Vertex AI");
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Tell me a story in 300 words."))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .stream(true)
+ .build();
+
+ System.out.println("Streaming response:");
+ CompletableFuture onCompleteFuture = new CompletableFuture<>();
+ client.async.interactions.create(CreateInteractionRequestBody.of(params))
+ .subscribe(new Subscriber() {
+ @Override
+ public void onSubscribe(Subscription s) {
+ s.request(Long.MAX_VALUE);
+ }
+
+ @Override
+ public void onNext(InteractionSSEStreamEvent streamEvent) {
+ InteractionSSEEvent event = streamEvent.data();
+ if (event.value() instanceof StepDelta) {
+ StepDelta stepDelta = (StepDelta) event.value();
+ StepDeltaData data = stepDelta.delta();
+ if (data.value() instanceof TextDelta) {
+ TextDelta textDelta = (TextDelta) data.value();
+ System.out.print(textDelta.text());
+ System.out.flush();
+ }
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ onCompleteFuture.completeExceptionally(t);
+ }
+
+ @Override
+ public void onComplete() {
+ onCompleteFuture.complete(null);
+ }
+ });
+
+ // Wait for the stream to complete.
+ onCompleteFuture.join();
+ System.out.println();
+
+ client.close();
+ }
+
+ private InteractionCreateAsyncStreaming() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java
new file mode 100644
index 00000000000..54fa674c4f8
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionCreateStreaming.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionCreateStreaming"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
+import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.StepDelta;
+import com.google.genai.gaos.models.interactions.StepDeltaData;
+import com.google.genai.gaos.models.interactions.TextDelta;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.gaos.models.operations.CreateInteractionResponse;
+import com.google.genai.gaos.utils.EventStream;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create a streaming interaction synchronously.
+ */
+public final class InteractionCreateStreaming {
+ public static void main(String[] args) throws Exception {
+ // Instantiate the client. The client by default uses the Gemini Developer API. It gets the API
+ // key from the environment variable `GOOGLE_API_KEY`. Vertex AI API can be used by setting the
+ // environment variables `GOOGLE_CLOUD_LOCATION` and `GOOGLE_CLOUD_PROJECT`, as well as setting
+ // `GOOGLE_GENAI_USE_VERTEXAI` to "true".
+ //
+ // Note: Some services are only available in a specific API backend (Gemini or Vertex), you will
+ // get a `UnsupportedOperationException` if you try to use a service that is not available in
+ // the backend you are using.
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Using Vertex AI");
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Tell me a story in 300 words."))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .stream(true)
+ .build();
+
+ CreateInteractionResponse response =
+ client.interactions.create(CreateInteractionRequestBody.of(params));
+
+ try (EventStream eventStream = response.events()) {
+ System.out.println("Streaming response:");
+ for (InteractionSSEStreamEvent streamEvent : eventStream) {
+ InteractionSSEEvent event = streamEvent.data();
+ if (event.value() instanceof StepDelta) {
+ StepDelta stepDelta = (StepDelta) event.value();
+ StepDeltaData data = stepDelta.delta();
+ if (data.value() instanceof TextDelta) {
+ TextDelta textDelta = (TextDelta) data.value();
+ System.out.print(textDelta.text());
+ System.out.flush();
+ }
+ }
+ }
+ System.out.println();
+ }
+ }
+
+ private InteractionCreateStreaming() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java b/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java
new file mode 100644
index 00000000000..92fc94dd121
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionDeepResearch.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2026 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:
+ *
+ * Deep Research is currently only available on Vertex AI.
+ *
+ *
1. Setup ADC to get credentials:
+ * https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp
+ *
+ *
2. Set Project, Location, and USE_VERTEXAI flag as environment variables:
+ *
+ *
export GOOGLE_CLOUD_PROJECT=YOUR_PROJECT
+ *
+ *
export GOOGLE_CLOUD_LOCATION=global
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
3. Compile the java package and run the sample code.
+ *
+ *
mvn clean compile exec:java
+ * -Dexec.mainClass="com.google.genai.examples.InteractionDeepResearch"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
+import com.google.genai.gaos.models.interactions.ErrorEvent;
+import com.google.genai.gaos.models.interactions.InteractionCompletedEvent;
+import com.google.genai.gaos.models.interactions.InteractionCreatedEvent;
+import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
+import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
+import com.google.genai.gaos.models.interactions.InteractionStatusUpdate;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.StepDelta;
+import com.google.genai.gaos.models.interactions.StepDeltaData;
+import com.google.genai.gaos.models.interactions.StepStart;
+import com.google.genai.gaos.models.interactions.StepStop;
+import com.google.genai.gaos.models.interactions.TextDelta;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.gaos.models.operations.CreateInteractionResponse;
+import com.google.genai.gaos.models.operations.GetInteractionByIdResponse;
+import com.google.genai.gaos.utils.EventStream;
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to run a Deep Research interaction on Vertex AI.
+ */
+public final class InteractionDeepResearch {
+ public static void main(String[] args) throws Exception {
+ // Instantiate the client. Deep Research requires Vertex AI.
+ // Ensure GOOGLE_CLOUD_PROJECT, GOOGLE_CLOUD_LOCATION=global, and
+ // GOOGLE_GENAI_USE_VERTEXAI=true are set in your environment.
+ Client client = new Client();
+
+ if (!client.vertexAI()) {
+ System.err.println("Deep Research is only supported on Vertex AI. "
+ + "Please set GOOGLE_GENAI_USE_VERTEXAI=true.");
+ return;
+ }
+
+ System.out.println(
+ "Using Vertex AI Project: " + (client.project() != null ? client.project() : "unknown"));
+
+ CreateAgentInteraction params =
+ CreateAgentInteraction.builder()
+ .agent("deep-research-pro-preview-12-2025")
+ .input(InteractionsInput.of("I want to learn more about the history of Hadrian's Wall"))
+ .background(true)
+ .stream(true)
+ .build();
+
+ AtomicReference interactionId = new AtomicReference<>();
+
+ System.out.println("--- Starting Deep Research Interaction ---");
+
+ CreateInteractionResponse createResponse =
+ client.interactions.create()
+ .apiVersion("v1beta1")
+ .body(CreateInteractionRequestBody.of(params))
+ .call();
+
+ try (EventStream eventStream = createResponse.events()) {
+ // We consume the first few events to capture the Interaction ID and see progress.
+ for (InteractionSSEStreamEvent streamEvent : eventStream) {
+ InteractionSSEEvent event = streamEvent.data();
+ if (event.value() instanceof InteractionCreatedEvent) {
+ InteractionCreatedEvent createdEvent = (InteractionCreatedEvent) event.value();
+ String id = createdEvent.interaction().id();
+ interactionId.set(id);
+ System.out.println("Started Interaction ID: " + id);
+ }
+ String eventType = "unknown";
+ if (event.value() instanceof InteractionCreatedEvent) {
+ eventType = "interaction.created";
+ } else if (event.value() instanceof InteractionCompletedEvent) {
+ eventType = "interaction.completed";
+ } else if (event.value() instanceof InteractionStatusUpdate) {
+ eventType = "interaction.status_update";
+ } else if (event.value() instanceof StepStart) {
+ eventType = "step.start";
+ } else if (event.value() instanceof StepDelta) {
+ eventType = "step.delta";
+ } else if (event.value() instanceof StepStop) {
+ eventType = "step.stop";
+ } else if (event.value() instanceof ErrorEvent) {
+ eventType = "error";
+ }
+
+ System.out.println("Event type: " + eventType);
+
+ // Stop consuming after capturing the ID or if the stream is complete
+ if (interactionId.get() != null) {
+ break;
+ }
+ }
+ }
+
+ String id = interactionId.get();
+ if (id == null) {
+ System.err.println("Failed to capture interaction ID.");
+ return;
+ }
+
+ // Deep research can take a long time. In a real application, you might poll or resume later.
+ // Here we resume the stream to wait for more output.
+ System.out.println("\n--- Resuming Interaction: " + id + " ---");
+ GetInteractionByIdResponse getResponse =
+ client.interactions.get(
+ com.google.genai.gaos.models.operations.GetInteractionByIdRequest.builder()
+ .apiVersion("v1beta1")
+ .id(id)
+ .stream(true)
+ .build());
+
+ try (EventStream eventStream = getResponse.events()) {
+ for (InteractionSSEStreamEvent streamEvent : eventStream) {
+ InteractionSSEEvent event = streamEvent.data();
+ if (event.value() instanceof InteractionStatusUpdate) {
+ InteractionStatusUpdate statusUpdate = (InteractionStatusUpdate) event.value();
+ System.out.println(
+ "\n[Status update: " + statusUpdate.status().value() + "]");
+ } else if (event.value() instanceof StepDelta) {
+ StepDelta stepDelta = (StepDelta) event.value();
+ StepDeltaData data = stepDelta.delta();
+ if (data.value() instanceof TextDelta) {
+ TextDelta textDelta = (TextDelta) data.value();
+ System.out.print(textDelta.text());
+ } else {
+ // If it's a content delta but doesn't have text (e.g. tool call
+ // or thought), print the type.
+ System.out.println("\n[Agent Activity]: " + data.value().getClass().getSimpleName());
+ }
+ }
+ }
+ System.out.println();
+ }
+ }
+
+ private InteractionDeepResearch() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java
new file mode 100644
index 00000000000..3d243985935
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingClientState.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionFunctionCallingClientState"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Function;
+import com.google.genai.gaos.models.interactions.FunctionCallStep;
+import com.google.genai.gaos.models.interactions.FunctionResultStep;
+import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.interactions.UserInputStep;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** An example of using the Unified Gen AI Java SDK to perform client-side function calling. */
+public final class InteractionFunctionCallingClientState {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ // 1. Define the function (tool)
+ Map attendeesSchema = new HashMap<>();
+ attendeesSchema.put("type", "array");
+ attendeesSchema.put("items", ImmutableMap.of("type", "string"));
+ attendeesSchema.put("description", "List of people attending the meeting.");
+
+ Map dateSchema = new HashMap<>();
+ dateSchema.put("type", "string");
+ dateSchema.put("description", "Date of the meeting (e.g., 2024-07-29)");
+
+ Map timeSchema = new HashMap<>();
+ timeSchema.put("type", "string");
+ timeSchema.put("description", "Time of the meeting (e.g., 15:00)");
+
+ Map topicSchema = new HashMap<>();
+ topicSchema.put("type", "string");
+ topicSchema.put("description", "The subject or topic of the meeting.");
+
+ Map properties = new HashMap<>();
+ properties.put("attendees", attendeesSchema);
+ properties.put("date", dateSchema);
+ properties.put("time", timeSchema);
+ properties.put("topic", topicSchema);
+
+ Map parametersSchema = new HashMap<>();
+ parametersSchema.put("type", "object");
+ parametersSchema.put("properties", properties);
+ parametersSchema.put("required", Arrays.asList("attendees", "date", "time", "topic"));
+
+ Function function =
+ Function.builder()
+ .name("schedule_meeting")
+ .description("Schedules a meeting with specified attendees at a given time and date.")
+ .parameters(parametersSchema)
+ .build();
+
+ // 2. Initialize conversation history
+ List conversationHistory = new ArrayList<>();
+ conversationHistory.add(
+ Step.of(
+ UserInputStep.builder()
+ .content(
+ ImmutableList.of(
+ Content.of(
+ TextContent.builder()
+ .text(
+ "Schedule a meeting for 2025-11-01 at 10 am with Peter and Amir"
+ + " about the Next Gen API")
+ .build())))
+ .build()));
+
+ // 3. First turn: Model decides to call the function
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_MODEL_NAME)
+ .input(InteractionsInput.ofStep(conversationHistory))
+ .tools(ImmutableList.of(Tool.of(function)))
+ .build();
+
+ Interaction response =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ String functionCallId = null;
+ String functionName = null;
+
+ if (response.steps().isPresent()) {
+ List steps = response.steps().get();
+ for (Step step : steps) {
+ if (step.value() instanceof FunctionCallStep) {
+ FunctionCallStep functionCall = (FunctionCallStep) step.value();
+ functionCallId = functionCall.id();
+ functionName = functionCall.name();
+ System.out.println("Model requested function call: " + functionName);
+ System.out.println("Arguments: " + functionCall.arguments());
+ } else if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(
+ contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println("Output Text: " + text.text());
+ }
+ }
+ });
+ }
+ }
+
+ // Add model response back to history
+ for (Step step : steps) {
+ conversationHistory.add(step);
+ }
+ }
+
+ // 4. Second turn: Send the function result back to the model
+ if (functionCallId != null) {
+ System.out.println("Sending function result back...");
+
+ FunctionResultStep functionResult =
+ FunctionResultStep.builder()
+ .callId(functionCallId)
+ .name(functionName)
+ .result(FunctionResultStepResultUnion.of("Meeting scheduled successfully."))
+ .build();
+
+ // Create a step with function result
+ conversationHistory.add(Step.of(functionResult));
+
+ CreateModelInteraction followUpParams =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_MODEL_NAME)
+ .input(InteractionsInput.ofStep(conversationHistory))
+ .build();
+
+ Interaction followUpResponse =
+ client.interactions.create(CreateInteractionRequestBody.of(followUpParams))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create follow up interaction"));
+
+ System.out.println("Final response status: " + followUpResponse.status());
+ followUpResponse.steps().ifPresent(followUpSteps -> {
+ for (Step step : followUpSteps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(
+ contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println("Final Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ } else {
+ System.out.println("No function call requested by the model.");
+ }
+ }
+
+ private InteractionFunctionCallingClientState() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java
new file mode 100644
index 00000000000..9c7cee94379
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionFunctionCallingServerState.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionFunctionCallingServerState"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Function;
+import com.google.genai.gaos.models.interactions.FunctionCallStep;
+import com.google.genai.gaos.models.interactions.FunctionResultStep;
+import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An example of using the Interactions API for multi-turn function calling where the state is
+ * managed by the server.
+ */
+public final class InteractionFunctionCallingServerState {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ // 1. Define the function (tool)
+ Map attendeesSchema = new HashMap<>();
+ attendeesSchema.put("type", "array");
+ attendeesSchema.put("items", ImmutableMap.of("type", "string"));
+ attendeesSchema.put("description", "List of people attending the meeting.");
+
+ Map dateSchema = new HashMap<>();
+ dateSchema.put("type", "string");
+ dateSchema.put("description", "Date of the meeting (e.g., 2024-07-29)");
+
+ Map timeSchema = new HashMap<>();
+ timeSchema.put("type", "string");
+ timeSchema.put("description", "Time of the meeting (e.g., 15:00)");
+
+ Map topicSchema = new HashMap<>();
+ topicSchema.put("type", "string");
+ topicSchema.put("description", "The subject or topic of the meeting.");
+
+ Map properties = new HashMap<>();
+ properties.put("attendees", attendeesSchema);
+ properties.put("date", dateSchema);
+ properties.put("time", timeSchema);
+ properties.put("topic", topicSchema);
+
+ Map parametersSchema = new HashMap<>();
+ parametersSchema.put("type", "object");
+ parametersSchema.put("properties", properties);
+ parametersSchema.put("required", Arrays.asList("attendees", "date", "time", "topic"));
+
+ Function function =
+ Function.builder()
+ .name("schedule_meeting")
+ .description("Schedules a meeting with specified attendees at a given time and date.")
+ .parameters(parametersSchema)
+ .build();
+
+ // 2. First turn: Model decides to call the function
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(
+ InteractionsInput.of(
+ "Schedule a meeting for 2025-11-01 at 10 am with Peter and Amir about the Next Gen"
+ + " API"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(function)))
+ .build();
+
+ Interaction response =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ String functionCallId = null;
+ String functionName = null;
+
+ if (response.steps().isPresent()) {
+ List steps = response.steps().get();
+ for (Step step : steps) {
+ if (step.value() instanceof FunctionCallStep) {
+ FunctionCallStep functionCall = (FunctionCallStep) step.value();
+ functionCallId = functionCall.id();
+ functionName = functionCall.name();
+ System.out.println("Model requested function call: " + functionName);
+ System.out.println("Arguments: " + functionCall.arguments());
+ } else if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(
+ contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println("Output Text: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ }
+
+ // 3. Second turn: Send the function result back to the model
+ if (functionCallId != null) {
+ System.out.println("Sending function result back...");
+
+ FunctionResultStep functionResult =
+ FunctionResultStep.builder()
+ .callId(functionCallId)
+ .name(functionName)
+ .result(FunctionResultStepResultUnion.of("Meeting scheduled successfully."))
+ .build();
+
+ CreateModelInteraction followUpParams =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_MODEL_NAME)
+ .previousInteractionId(response.id().orElse(""))
+ .input(InteractionsInput.ofStep(ImmutableList.of(Step.of(functionResult))))
+ .build();
+
+ Interaction followUpResponse =
+ client.interactions.create(CreateInteractionRequestBody.of(followUpParams))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create follow up interaction"));
+
+ System.out.println("Final response status: " + followUpResponse.status());
+ followUpResponse.steps().ifPresent(followUpSteps -> {
+ for (Step step : followUpSteps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(
+ contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println("Final Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ } else {
+ System.out.println("No function call requested by the model.");
+ }
+ }
+
+ private InteractionFunctionCallingServerState() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionGet.java b/examples/src/main/java/com/google/genai/examples/InteractionGet.java
new file mode 100644
index 00000000000..ff6fbcf21c6
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionGet.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionGet"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to retrieve an interaction. */
+public final class InteractionGet {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ // First, create an interaction to get an ID.
+ CreateModelInteraction createParams =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Why is the sky blue?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .build();
+
+ Interaction createdInteraction =
+ client.interactions.create(CreateInteractionRequestBody.of(createParams))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+ String id = createdInteraction.id().orElseThrow(() -> new RuntimeException("No ID returned"));
+ System.out.println("Created Interaction ID: " + id);
+
+ // Now, retrieve the interaction using the ID.
+ Interaction retrievedInteraction =
+ client.interactions.get(new com.google.genai.gaos.models.operations.GetInteractionByIdRequest(id))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to retrieve interaction"));
+ System.out.println("Retrieved Interaction ID: " + retrievedInteraction.id().orElse(""));
+ System.out.println("Status: " + retrievedInteraction.status());
+
+ // Print the text outputs from the retrieved interaction.
+ retrievedInteraction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionGet() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java
new file mode 100644
index 00000000000..f06705d351a
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndAudio.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2026 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
+ *
+ * http://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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalInputTextAndAudio"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.AudioContent;
+import com.google.genai.gaos.models.interactions.AudioContentMimeType;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Base64;
+import java.util.List;
+
+/** Example of using the Interactions API with multimodal input (text and audio). */
+public final class InteractionMultimodalInputTextAndAudio {
+
+ private InteractionMultimodalInputTextAndAudio() {}
+
+ private static void createInteractions(Client client) {
+ String base64Audio;
+ try {
+ base64Audio = Base64.getEncoder().encodeToString(
+ Files.readAllBytes(Paths.get("./resources/sample_audio.mp3"))
+ );
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read audio file", e);
+ }
+
+ Content textContent =
+ Content.of(TextContent.builder().text("Summarize this audio clip.").build());
+ Content audioContent =
+ Content.of(
+ AudioContent.builder()
+ .data(base64Audio)
+ .mimeType(AudioContentMimeType.AUDIO_MP3)
+ .build());
+
+ List contents = ImmutableList.of(textContent, audioContent);
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_3_5_FLASH_MODEL_NAME)
+ .input(InteractionsInput.ofContent(contents))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ for (int i = 0; i < steps.size(); i++) {
+ System.out.println("Step " + (i + 1) + ": " + steps.get(i));
+ }
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+ createInteractions(client);
+ }
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java
new file mode 100644
index 00000000000..8de52554893
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalInputTextAndImage.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2026 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
+ *
+ * http://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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalInputTextAndImage"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.ImageContent;
+import com.google.genai.gaos.models.interactions.ImageContentMimeType;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Base64;
+import java.util.List;
+
+/** Example of using the Interactions API with multimodal input (text and image). */
+public final class InteractionMultimodalInputTextAndImage {
+
+ private static void createInteractions(Client client) {
+ String base64Image;
+ try {
+ base64Image = Base64.getEncoder().encodeToString(
+ Files.readAllBytes(Paths.get("./resources/shapes.jpg"))
+ );
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read image file", e);
+ }
+
+ Content textContent =
+ Content.of(TextContent.builder().text("What is shown in this image?").build());
+ Content imageContent =
+ Content.of(
+ ImageContent.builder()
+ .data(base64Image)
+ .mimeType(ImageContentMimeType.IMAGE_JPEG)
+ .build());
+
+ List contents = ImmutableList.of(textContent, imageContent);
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_3_5_FLASH_MODEL_NAME)
+ .input(InteractionsInput.ofContent(contents))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ for (int i = 0; i < steps.size(); i++) {
+ System.out.println("Step " + (i + 1) + ": " + steps.get(i));
+ }
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+ createInteractions(client);
+ }
+
+ private InteractionMultimodalInputTextAndImage() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java
new file mode 100644
index 00000000000..91afc30dcfe
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudio.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2026 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
+ *
+ * http://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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalResponseAudio"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.GenerationConfig;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ResponseModality;
+import com.google.genai.gaos.models.interactions.SpeechConfig;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.Arrays;
+
+/** Example of generating audio using the Interactions API. */
+public final class InteractionMultimodalResponseAudio {
+
+ private static void createInteractions(Client client) {
+
+ SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build();
+
+ GenerationConfig generationConfig =
+ GenerationConfig.builder().speechConfig(ImmutableList.of(speechConfig)).build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model("gemini-2.5-flash-preview-tts")
+ .responseModalities(ImmutableList.of(ResponseModality.AUDIO))
+ .generationConfig(generationConfig)
+ .input(InteractionsInput.of("Say cheerfully: Have a wonderful day!"))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ interaction.steps().ifPresent(steps -> {
+ int i = 1;
+ for (Step step : steps) {
+ System.out.println("Output " + i + ": " + step);
+ i++;
+ }
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+ createInteractions(client);
+ }
+
+ private InteractionMultimodalResponseAudio() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java
new file mode 100644
index 00000000000..1c1498202fb
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseAudioWithGenerateContent.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalResponseAudioWithGenerateContent"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.JsonSerializable;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.GenerationConfig;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ResponseModality;
+import com.google.genai.gaos.models.interactions.SpeechConfig;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.types.GenerateContentConfig;
+import com.google.genai.types.GenerateContentResponse;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create an interaction with audio response and
+ * generate content with audio response.
+ */
+public final class InteractionMultimodalResponseAudioWithGenerateContent {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("[Interactions] Start interactions multimodal response audio");
+
+ SpeechConfig speechConfig = SpeechConfig.builder().voice("achernar").language("en-US").build();
+
+ GenerationConfig generationConfig =
+ GenerationConfig.builder().speechConfig(ImmutableList.of(speechConfig)).build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model("gemini-2.5-flash-preview-tts")
+ .responseModalities(ImmutableList.of(ResponseModality.AUDIO))
+ .generationConfig(generationConfig)
+ .input(InteractionsInput.of("Say cheerfully: Have a wonderful day!"))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ int stepIndex = 1;
+ for (Step step : steps) {
+ System.out.println("Step " + stepIndex + ": " + step);
+ stepIndex++;
+ }
+ });
+
+ System.out.println("[Generate Content] Start generate content");
+ GenerateContentConfig config =
+ GenerateContentConfig.builder().responseModalities(ImmutableList.of("AUDIO")).build();
+
+ GenerateContentResponse generateContentResponse =
+ client.models.generateContent(
+ "gemini-2.5-flash-preview-tts", "Say cheerfully: Have a wonderful day!", config);
+
+ System.out.println(
+ "Generate Content response: " + JsonSerializable.toJsonString(generateContentResponse));
+ }
+
+ private InteractionMultimodalResponseAudioWithGenerateContent() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java
new file mode 100644
index 00000000000..bf55458539d
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImage.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2026 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
+ *
+ * http://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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalResponseImage"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ResponseModality;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.Arrays;
+
+/** Example of generating an image using the Interactions API. */
+public class InteractionMultimodalResponseImage {
+
+ private static void createInteractions(Client client) {
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model("gemini-2.5-flash-image")
+ .responseModalities(Arrays.asList(ResponseModality.IMAGE))
+ .input(InteractionsInput.of("Generate an image of a futuristic cityscape at sunset."))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ interaction.steps().ifPresent(steps -> {
+ int i = 1;
+ for (Step step : steps) {
+ System.out.println("Output " + i + ": " + step);
+ i++;
+ }
+ });
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+ createInteractions(client);
+ }
+
+ private InteractionMultimodalResponseImage() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java
new file mode 100644
index 00000000000..72d202759e6
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionMultimodalResponseImageWithGenerateContent.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionMultimodalResponseImageWithGenerateContent"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.JsonSerializable;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ResponseModality;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.types.GenerateContentConfig;
+import com.google.genai.types.GenerateContentResponse;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create an interaction with image response and
+ * generate content with image response.
+ */
+public final class InteractionMultimodalResponseImageWithGenerateContent {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("[Interactions] Start interactions multimodal response image");
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model("gemini-2.5-flash-image")
+ .responseModalities(ImmutableList.of(ResponseModality.IMAGE))
+ .input(InteractionsInput.of("Generate an image of a futuristic cityscape at sunset."))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ int stepIndex = 1;
+ for (Step step : steps) {
+ System.out.println("Step " + stepIndex + ": " + step);
+ stepIndex++;
+ }
+ });
+
+ System.out.println("[Generate Content] Start generate content");
+ GenerateContentConfig config =
+ GenerateContentConfig.builder().responseModalities(ImmutableList.of("TEXT", "IMAGE")).build();
+
+ GenerateContentResponse generateContentResponse =
+ client.models.generateContent(
+ "gemini-2.5-flash-image",
+ "Generate an image of a futuristic cityscape at sunset.",
+ config);
+
+ System.out.println(
+ "Generate Content response: " + JsonSerializable.toJsonString(generateContentResponse));
+ }
+
+ private InteractionMultimodalResponseImageWithGenerateContent() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStateful.java b/examples/src/main/java/com/google/genai/examples/InteractionStateful.java
new file mode 100644
index 00000000000..a1ee3b3751c
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionStateful.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionStateful"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to create a stateful interaction. */
+public final class InteractionStateful {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex AI");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ System.out.println("User: What are the three largest cities in Spain?");
+ CreateModelInteraction params1 =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What are the three largest cities in Spain?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .build();
+
+ Interaction interaction1 =
+ client.interactions.create(CreateInteractionRequestBody.of(params1))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+ System.out.println("Model: ");
+ printOutput(interaction1);
+
+ System.out.println("\nUser: What is the most famous landmark in the second one?");
+ CreateModelInteraction params2 =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What is the most famous landmark in the second one?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .previousInteractionId(interaction1.id().orElseThrow(() -> new RuntimeException("No ID returned")))
+ .build();
+
+ Interaction interaction2 =
+ client.interactions.create(CreateInteractionRequestBody.of(params2))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+ System.out.println("Model: ");
+ printOutput(interaction2);
+ }
+
+ private static void printOutput(Interaction interaction) {
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println(text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionStateful() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStateless.java b/examples/src/main/java/com/google/genai/examples/InteractionStateless.java
new file mode 100644
index 00000000000..deadfdec7fd
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionStateless.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionStateless"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.UserInputStep;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create a stateless interaction (multi-turn
+ * chat).
+ */
+public final class InteractionStateless {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ List conversationHistory = new ArrayList<>();
+ conversationHistory.add(
+ Step.of(
+ UserInputStep.builder()
+ .content(
+ List.of(
+ Content.of(
+ TextContent.builder()
+ .text("What are the three largest cities in Spain?")
+ .build())))
+ .build()));
+
+ System.out.println("User: What are the three largest cities in Spain?");
+
+ CreateModelInteraction params1 =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.ofStep(conversationHistory))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .store(false)
+ .build();
+
+ Interaction response1 =
+ client.interactions.create(CreateInteractionRequestBody.of(params1))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Model: ");
+ // Add model response to history
+ response1.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println(text.text());
+ }
+ }
+ });
+ }
+ conversationHistory.add(step);
+ }
+ });
+
+ // Add next user message
+ conversationHistory.add(
+ Step.of(
+ UserInputStep.builder()
+ .content(
+ List.of(
+ Content.of(
+ TextContent.builder()
+ .text("What is the most famous landmark in the second one?")
+ .build())))
+ .build()));
+
+ System.out.println("\nUser: What is the most famous landmark in the second one?");
+
+ CreateModelInteraction params2 =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.ofStep(conversationHistory))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .store(false)
+ .build();
+
+ Interaction response2 =
+ client.interactions.create(CreateInteractionRequestBody.of(params2))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Model: ");
+ response2.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content output : contents) {
+ if (output.value() instanceof TextContent) {
+ TextContent text = (TextContent) output.value();
+ System.out.println(text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionStateless() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java b/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java
new file mode 100644
index 00000000000..c5ff3f843f7
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionStreaming.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionStreaming"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.InteractionSSEEvent;
+import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.StepDelta;
+import com.google.genai.gaos.models.interactions.StepDeltaData;
+import com.google.genai.gaos.models.interactions.TextDelta;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.gaos.models.operations.CreateInteractionResponse;
+import com.google.genai.gaos.utils.EventStream;
+
+/** An example of using the Unified Gen AI Java SDK to stream an interaction. */
+public final class InteractionStreaming {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex AI");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Tell me a story"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .stream(true)
+ .build();
+
+ CreateInteractionResponse response =
+ client.interactions.create(CreateInteractionRequestBody.of(params));
+
+ try (EventStream eventStream = response.events()) {
+ for (InteractionSSEStreamEvent streamEvent : eventStream) {
+ InteractionSSEEvent event = streamEvent.data();
+ if (event.value() instanceof StepDelta) {
+ StepDelta stepDelta = (StepDelta) event.value();
+ StepDeltaData data = stepDelta.delta();
+ if (data.value() instanceof TextDelta) {
+ TextDelta textDelta = (TextDelta) data.value();
+ System.out.print(textDelta.text());
+ System.out.flush();
+ }
+ }
+ }
+ System.out.println();
+ }
+ }
+
+ private InteractionStreaming() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java b/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java
new file mode 100644
index 00000000000..c7b225600a8
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionStructuredOutputJson.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2026 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
+ *
+ * http://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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionStructuredOutputJson"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.CreateModelInteractionResponseFormat;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ResponseFormat;
+import com.google.genai.gaos.models.interactions.TextResponseFormat;
+import com.google.genai.gaos.models.interactions.TextResponseFormatMimeType;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Example of requesting structured JSON output using the Interactions API. */
+public class InteractionStructuredOutputJson {
+
+ private static void createInteractions(Client client) {
+
+ Map format = new HashMap<>();
+ format.put("type", "array");
+ format.put("description", "A list of colors");
+
+ TextResponseFormat textResponseFormat = TextResponseFormat.builder()
+ .mimeType(TextResponseFormatMimeType.APPLICATION_JSON)
+ .schema(format)
+ .build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model(Constants.GEMINI_MODEL_NAME)
+ .input(InteractionsInput.of("Which are the colors of a rainbow"))
+ .responseFormat(CreateModelInteractionResponseFormat.of(ResponseFormat.of(textResponseFormat)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println(interaction);
+ }
+
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+ createInteractions(client);
+ }
+
+ private InteractionStructuredOutputJson() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java
new file mode 100644
index 00000000000..8b24394000b
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithCodeExecution.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithCodeExecution"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.CodeExecution;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Interactions API with code execution tool. */
+public final class InteractionToolCallWithCodeExecution {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ CodeExecution codeExecution = CodeExecution.builder().build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What is the sum of the first 100 integers?"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(codeExecution)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithCodeExecution() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java
new file mode 100644
index 00000000000..3fa0a443686
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithComputerUse.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithComputerUse"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.ComputerUse;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.EnvironmentEnum;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/**
+ * An example of using the Unified Gen AI Java SDK to create an interaction with computer use tool.
+ */
+public final class InteractionToolCallWithComputerUse {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ } else {
+ System.out.println("Using Gemini Developer API");
+ }
+
+ ComputerUse computerUse =
+ ComputerUse.builder()
+ .environment(EnvironmentEnum.BROWSER)
+ .build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .model("gemini-2.5-computer-use-preview-10-2025")
+ .input(
+ InteractionsInput.of(
+ "Search for highly rated smart fridges with touchscreen, 2 doors, around 25 cu ft,"
+ + " priced below 4000 dollars on Google Shopping. Create a bulleted list of the"
+ + " 3 cheapest options in the format of name, description, price in an"
+ + " easy-to-read layout."))
+ .tools(ImmutableList.of(Tool.of(computerUse)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithComputerUse() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java
new file mode 100644
index 00000000000..b9d8e42d83c
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithFunctions.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithFunctions"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Function;
+import com.google.genai.gaos.models.interactions.FunctionCallStep;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to perform tool calling with functions. */
+public final class InteractionToolCallWithFunctions {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex AI");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ ImmutableMap attendeesSchema =
+ ImmutableMap.of(
+ "type",
+ "array",
+ "items",
+ ImmutableMap.of("type", "string"),
+ "description",
+ "List of people attending the meeting.");
+ ImmutableMap dateSchema =
+ ImmutableMap.of("type", "string", "description", "Date of the meeting (e.g., 2024-07-29)");
+ ImmutableMap timeSchema =
+ ImmutableMap.of("type", "string", "description", "Time of the meeting (e.g., 15:00)");
+ ImmutableMap topicSchema =
+ ImmutableMap.of("type", "string", "description", "The subject or topic of the meeting.");
+
+ ImmutableMap properties =
+ ImmutableMap.of(
+ "attendees",
+ attendeesSchema,
+ "date",
+ dateSchema,
+ "time",
+ timeSchema,
+ "topic",
+ topicSchema);
+
+ ImmutableMap parametersSchema =
+ ImmutableMap.of(
+ "type",
+ "object",
+ "properties",
+ properties,
+ "required",
+ ImmutableList.of("attendees", "date", "time", "topic"));
+
+ Function function =
+ Function.builder()
+ .name("schedule_meeting")
+ .description("Schedules a meeting with specified attendees at a given time and date.")
+ .parameters(parametersSchema)
+ .build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of(
+ "Schedule a meeting for 10/06/2028 at 10 am with Peter and Amir about the Next Gen"
+ + " API"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(function)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof FunctionCallStep) {
+ FunctionCallStep fc = (FunctionCallStep) step.value();
+ System.out.println("Function Call: " + fc.name());
+ System.out.println("Arguments: " + fc.arguments());
+ } else if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output Text: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithFunctions() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java
new file mode 100644
index 00000000000..7521e134b35
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithGoogleSearch.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithGoogleSearch"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.GoogleSearch;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to perform tool calling with Google Search. */
+public final class InteractionToolCallWithGoogleSearch {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex AI");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ GoogleSearch googleSearch = GoogleSearch.builder().build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Why is the sky blue"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(googleSearch)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output Text: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithGoogleSearch() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java
new file mode 100644
index 00000000000..4f447dfd6d6
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithMcpServer.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithMcpServer"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.MCPServer;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Interactions API with an MCP server tool. */
+public final class InteractionToolCallWithMcpServer {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ MCPServer mcpServer =
+ MCPServer.builder()
+ .name("weather_service")
+ .url("https://gemini-api-demos.uc.r.appspot.com/mcp")
+ .build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("What is the temperature today in London?"))
+ .systemInstruction(
+ "Today is 9-23-2025. Any dates before this are in the past, and any dates after"
+ + " this are in the future.")
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(mcpServer)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithMcpServer() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java
new file mode 100644
index 00000000000..387f27b74a7
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionToolCallWithUrlContext.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionToolCallWithUrlContext"
+ */
+package com.google.genai.examples;
+
+import com.google.common.collect.ImmutableList;
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.interactions.Tool;
+import com.google.genai.gaos.models.interactions.URLContext;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Interactions API with URL context tool. */
+public final class InteractionToolCallWithUrlContext {
+ public static void main(String[] args) throws Exception {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ URLContext urlContext = URLContext.builder().build();
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(
+ InteractionsInput.of(
+ "Compare the ingredients and cooking times from the recipes at"
+ + " https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"
+ + " and https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .tools(ImmutableList.of(Tool.of(urlContext)))
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ // Print the text outputs from the interaction.
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionToolCallWithUrlContext() {}
+}
diff --git a/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java b/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java
new file mode 100644
index 00000000000..db4cb7fe434
--- /dev/null
+++ b/examples/src/main/java/com/google/genai/examples/InteractionWithConfig.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2026 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
+ *
+ *
export GOOGLE_GENAI_USE_VERTEXAI=true
+ *
+ *
1b. If you are using Gemini Developer API, 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.InteractionWithConfig"
+ */
+package com.google.genai.examples;
+
+import com.google.genai.Client;
+import com.google.genai.gaos.models.interactions.Content;
+import com.google.genai.gaos.models.interactions.CreateModelInteraction;
+import com.google.genai.gaos.models.interactions.Interaction;
+import com.google.genai.gaos.models.interactions.InteractionsInput;
+import com.google.genai.gaos.models.interactions.ModelOutputStep;
+import com.google.genai.gaos.models.interactions.Step;
+import com.google.genai.gaos.models.interactions.TextContent;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+
+/** An example of using the Unified Gen AI Java SDK to create an interaction with config. */
+public final class InteractionWithConfig {
+ public static void main(String[] args) {
+ Client client = new Client();
+
+ if (client.vertexAI()) {
+ System.out.println("Interactions API is not yet supported on Vertex AI");
+ return;
+ }
+
+ System.out.println("Using Gemini Developer API");
+
+ CreateModelInteraction params =
+ CreateModelInteraction.builder()
+ .input(InteractionsInput.of("Tell me a story"))
+ .model(Constants.GEMINI_MODEL_NAME)
+ .systemInstruction("You are a helpful assistant")
+ .build();
+
+ Interaction interaction =
+ client.interactions.create(CreateInteractionRequestBody.of(params))
+ .interaction()
+ .orElseThrow(() -> new RuntimeException("Failed to create interaction"));
+
+ System.out.println("Interaction ID: " + interaction.id().orElse(""));
+ System.out.println("Status: " + interaction.status());
+
+ interaction.steps().ifPresent(steps -> {
+ for (Step step : steps) {
+ if (step.value() instanceof ModelOutputStep) {
+ ModelOutputStep modelOutput = (ModelOutputStep) step.value();
+ modelOutput.content().ifPresent(contents -> {
+ for (Content content : contents) {
+ if (content.value() instanceof TextContent) {
+ TextContent text = (TextContent) content.value();
+ System.out.println("Output: " + text.text());
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private InteractionWithConfig() {}
+}
diff --git a/pom.xml b/pom.xml
index 90f687c09f1..4804b6ccc10 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,6 +54,7 @@
5.11.4
1.6.0
4.12.0
+ 1.9.10
src/main/java
src/test/java
@@ -122,6 +123,11 @@
okhttp
${okhttp.version}
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ 1.9.10
+
com.google.protobuf
protobuf-java
@@ -158,11 +164,6 @@
jspecify
1.0.0
-
- org.jetbrains.kotlin
- kotlin-stdlib-jdk8
- 1.9.10
-
@@ -301,6 +302,18 @@
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ checkstyle
+
+ **/gaos/**/*.java
+
+
+
+
org.jacoco
jacoco-maven-plugin
@@ -391,52 +404,7 @@
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.6.0
-
-
- package
-
- shade
-
-
-
-
- org.jetbrains.kotlin:kotlin-stdlib-jdk8
- org.jetbrains.kotlin:kotlin-stdlib
- org.jetbrains.kotlin:kotlin-reflect
- com.fasterxml.jackson.module:jackson-module-kotlin
-
-
-
-
-
-
-
- kotlin.
- com.google.genai.shaded.kotlin.
-
-
- com.fasterxml.jackson.module.kotlin.
- com.google.genai.shaded.jackson.module.kotlin.
-
-
-
-
- *:*
-
- META-INF/*.SF
- META-INF/*.DSA
- META-INF/*.RSA
-
-
-
-
-
-
-
+
org.codehaus.mojo
build-helper-maven-plugin
@@ -456,9 +424,17 @@
+
+ org.codehaus.mojo
+ animal-sniffer-maven-plugin
+
+ true
+
+
+
jdk8-build
diff --git a/src/main/java/com/google/genai/ApiClient.java b/src/main/java/com/google/genai/ApiClient.java
index 3119b6b2f9c..5696d859b3d 100644
--- a/src/main/java/com/google/genai/ApiClient.java
+++ b/src/main/java/com/google/genai/ApiClient.java
@@ -77,6 +77,7 @@ public abstract class ApiClient implements AutoCloseable {
HttpOptions httpOptions;
final boolean vertexAI;
final Optional clientOptions;
+
final Optional customBaseUrl;
// For Google AI APIs
final Optional apiKey;
@@ -120,6 +121,7 @@ protected ApiClient(
}
this.httpClient = createHttpClient(httpOptions, clientOptions);
+
}
ApiClient(
@@ -274,6 +276,7 @@ protected ApiClient(
}
this.vertexAI = true;
this.httpClient = createHttpClient(httpOptions, clientOptions);
+
}
private OkHttpClient createHttpClient(
@@ -371,6 +374,8 @@ private void applyProxyOptions(ProxyOptions proxyOptions, OkHttpClient.Builder b
}
}
+
+
/** Builds a HTTP request given the http method, path, and request json string. */
@SuppressWarnings("unchecked")
protected Request buildRequest(
@@ -910,6 +915,7 @@ public void close() {
if (httpClient().cache() != null) {
httpClient().cache().close();
}
+
} catch (IOException e) {
throw new GenAiIOException("Failed to close the client.", e);
}
diff --git a/src/main/java/com/google/genai/Client.java b/src/main/java/com/google/genai/Client.java
index 763d04507f8..017bd36bfdd 100644
--- a/src/main/java/com/google/genai/Client.java
+++ b/src/main/java/com/google/genai/Client.java
@@ -21,6 +21,13 @@
import com.google.auth.oauth2.GoogleCredentials;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
+// android:strip_begin
+import com.google.genai.gaos.GenAI;
+import com.google.genai.gaos.AsyncGenAI;
+import com.google.genai.gaos.SecuritySource;
+import com.google.genai.gaos.utils.HasSecurity;
+import java.io.IOException;
+// android:strip_end
import com.google.genai.types.ClientOptions;
import com.google.genai.types.HttpOptions;
import java.util.Optional;
@@ -43,6 +50,11 @@ public final class Async {
public final AsyncTokens authTokens;
public final AsyncTunings tunings;
public final AsyncFileSearchStores fileSearchStores;
+ // android:strip_begin
+ public final com.google.genai.gaos.AsyncInteractions interactions;
+ public final com.google.genai.gaos.AsyncAgents agents;
+ public final com.google.genai.gaos.AsyncWebhooks webhooks;
+ // android:strip_end
public Async(ApiClient apiClient) {
this.models = new AsyncModels(apiClient);
@@ -55,6 +67,12 @@ public Async(ApiClient apiClient) {
this.authTokens = new AsyncTokens(apiClient);
this.tunings = new AsyncTunings(apiClient);
this.fileSearchStores = new AsyncFileSearchStores(apiClient);
+ // android:strip_begin
+ AsyncGenAI asyncGaos = Client.this.gaosClient.async();
+ this.interactions = asyncGaos.interactions();
+ this.agents = asyncGaos.agents();
+ this.webhooks = asyncGaos.webhooks();
+ // android:strip_end
}
}
@@ -70,6 +88,12 @@ public Async(ApiClient apiClient) {
public final Tokens authTokens;
public final Tunings tunings;
public final FileSearchStores fileSearchStores;
+ // android:strip_begin
+ private final GenAI gaosClient;
+ public final com.google.genai.gaos.Interactions interactions;
+ public final com.google.genai.gaos.Agents agents;
+ public final com.google.genai.gaos.Webhooks webhooks;
+ // android:strip_end
/** Builder for {@link Client}. */
public static class Builder {
@@ -315,11 +339,62 @@ private Client(
caches = new Caches(apiClient);
operations = new Operations(this.apiClient);
chats = new Chats(this.apiClient);
+
+ // android:strip_begin
+ GenAI.Builder gaosBuilder = GenAI.builder();
+ this.apiClient.httpOptions().baseUrl().ifPresent(gaosBuilder::serverURL);
+ this.apiClient.httpOptions().apiVersion().ifPresent(gaosBuilder::apiVersion);
+ gaosBuilder.apiRevision("2026-05-20");
+ if (apiClient.credentials() != null && apiClient.credentials().getQuotaProjectId() != null) {
+ gaosBuilder.userProject(apiClient.credentials().getQuotaProjectId());
+ }
+ gaosBuilder.securitySource(new SecuritySource() {
+ @Override
+ public HasSecurity getSecurity() {
+ com.google.genai.gaos.models.shared.Security.Builder builder = com.google.genai.gaos.models.shared.Security.builder();
+ if (apiClient.apiKey() != null) {
+ builder.apiKey(apiClient.apiKey());
+ } else if (apiClient.credentials() != null) {
+ GoogleCredentials creds = apiClient.credentials();
+ try {
+ creds.refreshIfExpired();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to refresh credentials for GAOS client", e);
+ }
+ builder.accessToken(creds.getAccessToken().getTokenValue());
+ }
+ java.util.Map headersMap = new java.util.HashMap<>();
+ apiClient.httpOptions().headers().ifPresent(headersMap::putAll);
+ // DO_NOT_SUBMIT
+ headersMap.put("Api-Revision", "2026-05-20");
+ String ua = headersMap.get("user-agent");
+ if (ua != null) {
+ headersMap.put("user-agent", ua.replaceAll("google-genai-sdk/1\\.[0-9]+\\.[0-9]+", "google-genai-sdk/2.0.0"));
+ } else {
+ headersMap.put("user-agent", "google-genai-sdk/2.0.0 gl-java/" + System.getProperty("java.version"));
+ }
+ String xgac = headersMap.get("x-goog-api-client");
+ if (xgac != null) {
+ headersMap.put("x-goog-api-client", xgac.replaceAll("google-genai-sdk/1\\.[0-9]+\\.[0-9]+", "google-genai-sdk/2.0.0"));
+ } else {
+ headersMap.put("x-goog-api-client", "google-genai-sdk/2.0.0 gl-java/" + System.getProperty("java.version"));
+ }
+ builder.defaultHeaders(headersMap);
+ return builder.build();
+ }
+ });
+ this.gaosClient = gaosBuilder.build();
+ this.interactions = gaosClient.interactions();
+ this.agents = gaosClient.agents();
+ this.webhooks = gaosClient.webhooks();
+ // android:strip_end
+
async = new Async(this.apiClient);
files = new Files(this.apiClient);
authTokens = new Tokens(this.apiClient);
tunings = new Tunings(this.apiClient);
fileSearchStores = new FileSearchStores(this.apiClient);
+
}
/** Returns whether the client is using Vertex AI APIs. */
diff --git a/src/main/java/com/google/genai/gaos/Agents.java b/src/main/java/com/google/genai/gaos/Agents.java
new file mode 100644
index 00000000000..318c45ffc8e
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/Agents.java
@@ -0,0 +1,263 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.RequestOperation;
+
+import com.google.genai.gaos.models.agents.Agent;
+import com.google.genai.gaos.models.operations.CreateAgentRequest;
+import com.google.genai.gaos.models.operations.CreateAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.CreateAgentResponse;
+import com.google.genai.gaos.models.operations.DeleteAgentRequest;
+import com.google.genai.gaos.models.operations.DeleteAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.DeleteAgentResponse;
+import com.google.genai.gaos.models.operations.GetAgentRequest;
+import com.google.genai.gaos.models.operations.GetAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.GetAgentResponse;
+import com.google.genai.gaos.models.operations.ListAgentsRequest;
+import com.google.genai.gaos.models.operations.ListAgentsRequestBuilder;
+import com.google.genai.gaos.models.operations.ListAgentsResponse;
+import com.google.genai.gaos.operations.CreateAgent;
+import com.google.genai.gaos.operations.DeleteAgent;
+import com.google.genai.gaos.operations.GetAgent;
+import com.google.genai.gaos.operations.ListAgents;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import java.lang.Integer;
+import java.lang.String;
+import java.util.Optional;
+
+
+@SuppressWarnings("all")
+public class Agents {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final AsyncAgents asyncSDK;
+
+ Agents(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.asyncSDK = new AsyncAgents(this, sdkConfiguration);
+ }
+
+ /**
+ * Switches to the async SDK.
+ *
+ * @return The async SDK
+ */
+ public AsyncAgents async() {
+ return asyncSDK;
+ }
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @return The call builder
+ */
+ public CreateAgentRequestBuilder create() {
+ return new CreateAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @param body An agent definition for the CreateAgent API.
+ * This message is the target for annotation-parser-based JSON parsing.
+ * New format:
+ * {
+ * "id": "customer-sentinel",
+ * "base_agent": "",
+ * "system_instruction": "...",
+ * "base_environment": { "type": "remote", "sources": [...] },
+ * "tools": [ {"type": "code_execution"} ]
+ * }
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateAgentResponse create(Agent body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body An agent definition for the CreateAgent API.
+ * This message is the target for annotation-parser-based JSON parsing.
+ * New format:
+ * {
+ * "id": "customer-sentinel",
+ * "base_agent": "",
+ * "system_instruction": "...",
+ * "base_environment": { "type": "remote", "sources": [...] },
+ * "tools": [ {"type": "code_execution"} ]
+ * }
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateAgentResponse create(
+ Optional apiVersion, Agent body,
+ Optional options) {
+ CreateAgentRequest request =
+ CreateAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new CreateAgent.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Lists all Agents.
+ *
+ * @return The call builder
+ */
+ public ListAgentsRequestBuilder list() {
+ return new ListAgentsRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Lists all Agents.
+ *
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListAgentsResponse listDirect() {
+ return list(Optional.empty(), Optional.empty(), Optional.empty(),
+ Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Lists all Agents.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param pageSize
+ * @param pageToken
+ * @param parent
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListAgentsResponse list(
+ Optional apiVersion, Optional pageSize,
+ Optional pageToken, Optional parent,
+ Optional options) {
+ ListAgentsRequest request =
+ ListAgentsRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .pageSize(pageSize)
+ .pageToken(pageToken)
+ .parent(parent)
+ .build();
+ RequestOperation operation
+ = new ListAgents.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @return The call builder
+ */
+ public GetAgentRequestBuilder get() {
+ return new GetAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @param id
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetAgentResponse get(String id) {
+ return get(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetAgentResponse get(
+ Optional apiVersion, String id,
+ Optional options) {
+ GetAgentRequest request =
+ GetAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ RequestOperation operation
+ = new GetAgent.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Deletes an Agent.
+ *
+ * @return The call builder
+ */
+ public DeleteAgentRequestBuilder delete() {
+ return new DeleteAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deletes an Agent.
+ *
+ * @param id
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteAgentResponse delete(String id) {
+ return delete(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Deletes an Agent.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteAgentResponse delete(
+ Optional apiVersion, String id,
+ Optional options) {
+ DeleteAgentRequest request =
+ DeleteAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ RequestOperation operation
+ = new DeleteAgent.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/AsyncAgents.java b/src/main/java/com/google/genai/gaos/AsyncAgents.java
new file mode 100644
index 00000000000..ac0597f42b8
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/AsyncAgents.java
@@ -0,0 +1,273 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation;
+
+import com.google.genai.gaos.models.agents.Agent;
+import com.google.genai.gaos.models.operations.CreateAgentRequest;
+import com.google.genai.gaos.models.operations.DeleteAgentRequest;
+import com.google.genai.gaos.models.operations.GetAgentRequest;
+import com.google.genai.gaos.models.operations.ListAgentsRequest;
+import com.google.genai.gaos.models.operations.async.CreateAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.async.CreateAgentResponse;
+import com.google.genai.gaos.models.operations.async.DeleteAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.async.DeleteAgentResponse;
+import com.google.genai.gaos.models.operations.async.GetAgentRequestBuilder;
+import com.google.genai.gaos.models.operations.async.GetAgentResponse;
+import com.google.genai.gaos.models.operations.async.ListAgentsRequestBuilder;
+import com.google.genai.gaos.models.operations.async.ListAgentsResponse;
+import com.google.genai.gaos.operations.CreateAgent;
+import com.google.genai.gaos.operations.DeleteAgent;
+import com.google.genai.gaos.operations.GetAgent;
+import com.google.genai.gaos.operations.ListAgents;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import java.lang.Integer;
+import java.lang.String;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+
+@SuppressWarnings("all")
+public class AsyncAgents {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final Agents syncSDK;
+
+ AsyncAgents(Agents syncSDK, SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.syncSDK = syncSDK;
+ }
+
+ /**
+ * Switches to the sync SDK.
+ *
+ * @return The sync SDK
+ */
+ public Agents sync() {
+ return syncSDK;
+ }
+
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @return The async call builder
+ */
+ public CreateAgentRequestBuilder create() {
+ return new CreateAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @param body An agent definition for the CreateAgent API.
+ * This message is the target for annotation-parser-based JSON parsing.
+ * New format:
+ * {
+ * "id": "customer-sentinel",
+ * "base_agent": "",
+ * "system_instruction": "...",
+ * "base_environment": { "type": "remote", "sources": [...] },
+ * "tools": [ {"type": "code_execution"} ]
+ * }
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture create(Agent body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creates a new Agent (Typed version for SDK).
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body An agent definition for the CreateAgent API.
+ * This message is the target for annotation-parser-based JSON parsing.
+ * New format:
+ * {
+ * "id": "customer-sentinel",
+ * "base_agent": "",
+ * "system_instruction": "...",
+ * "base_environment": { "type": "remote", "sources": [...] },
+ * "tools": [ {"type": "code_execution"} ]
+ * }
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture create(
+ Optional apiVersion, Agent body,
+ Optional options) {
+ CreateAgentRequest request =
+ CreateAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new CreateAgent.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Lists all Agents.
+ *
+ * @return The async call builder
+ */
+ public ListAgentsRequestBuilder list() {
+ return new ListAgentsRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Lists all Agents.
+ *
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture listDirect() {
+ return list(
+ Optional.empty(), Optional.empty(), Optional.empty(),
+ Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Lists all Agents.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param pageSize
+ * @param pageToken
+ * @param parent
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture list(
+ Optional apiVersion, Optional pageSize,
+ Optional pageToken, Optional parent,
+ Optional options) {
+ ListAgentsRequest request =
+ ListAgentsRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .pageSize(pageSize)
+ .pageToken(pageToken)
+ .parent(parent)
+ .build();
+ AsyncRequestOperation operation
+ = new ListAgents.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @return The async call builder
+ */
+ public GetAgentRequestBuilder get() {
+ return new GetAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @param id
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture get(String id) {
+ return get(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Gets a specific Agent.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture get(
+ Optional apiVersion, String id,
+ Optional options) {
+ GetAgentRequest request =
+ GetAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ AsyncRequestOperation operation
+ = new GetAgent.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Deletes an Agent.
+ *
+ * @return The async call builder
+ */
+ public DeleteAgentRequestBuilder delete() {
+ return new DeleteAgentRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deletes an Agent.
+ *
+ * @param id
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(String id) {
+ return delete(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Deletes an Agent.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(
+ Optional apiVersion, String id,
+ Optional options) {
+ DeleteAgentRequest request =
+ DeleteAgentRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ AsyncRequestOperation operation
+ = new DeleteAgent.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/AsyncGenAI.java b/src/main/java/com/google/genai/gaos/AsyncGenAI.java
new file mode 100644
index 00000000000..bd42db30561
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/AsyncGenAI.java
@@ -0,0 +1,74 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import com.google.genai.gaos.utils.Headers;
+
+/**
+ * Gemini API: The Gemini Interactions API allows developers to build generative AI applications using
+ * Gemini models. Gemini is our most capable model, built from the ground up to be multimodal. It can
+ * generalize and seamlessly understand, operate across, and combine different types of information
+ * including language, images, audio, video, and code.
+ *
+ * You can use the Gemini API for use cases like reasoning across text and images, content generation,
+ * dialogue agents, summarization and classification systems, and more.
+ */
+@SuppressWarnings("all")
+public class AsyncGenAI {
+ private static final Headers _headers = Headers.EMPTY;
+
+ private final AsyncInteractions interactions;
+
+ private final AsyncWebhooks webhooks;
+
+ private final AsyncAgents agents;
+
+ public AsyncInteractions interactions() {
+ return interactions;
+ }
+
+ public AsyncWebhooks webhooks() {
+ return webhooks;
+ }
+
+ public AsyncAgents agents() {
+ return agents;
+ }
+
+ private final SDKConfiguration sdkConfiguration;
+ private final GenAI syncSDK;
+
+ AsyncGenAI(GenAI syncSDK, SDKConfiguration sdkConfiguration) {
+ this.syncSDK = syncSDK;
+ this.sdkConfiguration = sdkConfiguration;
+ this.interactions = new AsyncInteractions(syncSDK.interactions(), sdkConfiguration);
+ this.webhooks = new AsyncWebhooks(syncSDK.webhooks(), sdkConfiguration);
+ this.agents = new AsyncAgents(syncSDK.agents(), sdkConfiguration);
+ }
+
+ /**
+ * Switches to the sync SDK.
+ *
+ * @return The sync SDK
+ */
+ public GenAI sync() {
+ return syncSDK;
+ }
+}
diff --git a/src/main/java/com/google/genai/gaos/AsyncInteractions.java b/src/main/java/com/google/genai/gaos/AsyncInteractions.java
new file mode 100644
index 00000000000..7209bded0e3
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/AsyncInteractions.java
@@ -0,0 +1,277 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.google.genai.gaos.models.interactions.InteractionSSEStreamEvent;
+import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest;
+import com.google.genai.gaos.models.operations.CreateInteractionRequest;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.gaos.models.operations.DeleteInteractionRequest;
+import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
+import com.google.genai.gaos.models.operations.async.CancelInteractionByIdRequestBuilder;
+import com.google.genai.gaos.models.operations.async.CancelInteractionByIdResponse;
+import com.google.genai.gaos.models.operations.async.CreateInteractionRequestBuilder;
+import com.google.genai.gaos.models.operations.async.CreateInteractionResponse;
+import com.google.genai.gaos.models.operations.async.DeleteInteractionRequestBuilder;
+import com.google.genai.gaos.models.operations.async.DeleteInteractionResponse;
+import com.google.genai.gaos.models.operations.async.GetInteractionByIdRequestBuilder;
+import com.google.genai.gaos.models.operations.async.GetInteractionByIdResponse;
+import com.google.genai.gaos.operations.CancelInteractionById;
+import com.google.genai.gaos.operations.CreateInteraction;
+import com.google.genai.gaos.operations.DeleteInteraction;
+import com.google.genai.gaos.operations.GetInteractionById;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import com.google.genai.gaos.utils.Utils;
+import com.google.genai.gaos.utils.reactive.EventStream;
+import java.lang.String;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+
+@SuppressWarnings("all")
+public class AsyncInteractions {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final Interactions syncSDK;
+
+ AsyncInteractions(Interactions syncSDK, SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.syncSDK = syncSDK;
+ }
+
+ /**
+ * Switches to the sync SDK.
+ *
+ * @return The sync SDK
+ */
+ public Interactions sync() {
+ return syncSDK;
+ }
+
+
+ /**
+ * Creating an interaction
+ *
+ *
Creates a new interaction.
+ *
+ * @return The async call builder
+ */
+ public CreateInteractionRequestBuilder create() {
+ return new CreateInteractionRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creating an interaction
+ *
+ *
Creates a new interaction.
+ *
+ * @param body The request body.
+ * @return {@code EventStream} - The async response
+ */
+ public EventStream create(CreateInteractionRequestBody body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creating an interaction
+ *
+ * Creates a new interaction.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body The request body.
+ * @param options additional options
+ * @return A reactive SSE publisher that emits events from the server.
+ * Can be consumed using reactive streams toolkits such as RxJava, Project Reactor, or Java 9+ Flow API.
+ */
+ public EventStream create(
+ Optional apiVersion, CreateInteractionRequestBody body,
+ Optional options) {
+ CreateInteractionRequest request =
+ CreateInteractionRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new CreateInteraction.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return EventStream.forSSE(
+ operation.doRequest(request).thenCompose(operation::handleResponse),
+ new TypeReference<>() {
+ },
+ Utils.mapper(),
+ "[DONE]");
+ }
+
+
+ /**
+ * Retrieving an interaction
+ *
+ * Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @return The async call builder
+ */
+ public GetInteractionByIdRequestBuilder get() {
+ return new GetInteractionByIdRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Retrieving an interaction
+ *
+ *
Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @param request The request object containing all the parameters for the API call.
+ * @return {@code EventStream} - The async response
+ */
+ public EventStream get(GetInteractionByIdRequest request) {
+ return get(request, Optional.empty());
+ }
+
+ /**
+ * Retrieving an interaction
+ *
+ * Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @param request The request object containing all the parameters for the API call.
+ * @param options additional options
+ * @return A reactive SSE publisher that emits events from the server.
+ * Can be consumed using reactive streams toolkits such as RxJava, Project Reactor, or Java 9+ Flow API.
+ */
+ public EventStream get(GetInteractionByIdRequest request, Optional options) {
+ AsyncRequestOperation operation
+ = new GetInteractionById.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return EventStream.forSSE(
+ operation.doRequest(request).thenCompose(operation::handleResponse),
+ new TypeReference<>() {
+ },
+ Utils.mapper(),
+ "[DONE]");
+ }
+
+
+ /**
+ * Deleting an interaction
+ *
+ * Deletes the interaction by id.
+ *
+ * @return The async call builder
+ */
+ public DeleteInteractionRequestBuilder delete() {
+ return new DeleteInteractionRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deleting an interaction
+ *
+ *
Deletes the interaction by id.
+ *
+ * @param id The unique identifier of the interaction to delete.
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(String id) {
+ return delete(id, Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Deleting an interaction
+ *
+ * Deletes the interaction by id.
+ *
+ * @param id The unique identifier of the interaction to delete.
+ * @param apiVersion Which version of the API to use.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(
+ String id, Optional apiVersion,
+ Optional options) {
+ DeleteInteractionRequest request =
+ DeleteInteractionRequest
+ .builder()
+ .id(id)
+ .apiVersion(apiVersion)
+ .build();
+ AsyncRequestOperation operation
+ = new DeleteInteraction.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Canceling an interaction
+ *
+ * Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @return The async call builder
+ */
+ public CancelInteractionByIdRequestBuilder cancel() {
+ return new CancelInteractionByIdRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Canceling an interaction
+ *
+ *
Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @param id The unique identifier of the interaction to cancel.
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture cancel(String id) {
+ return cancel(id, Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Canceling an interaction
+ *
+ * Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @param id The unique identifier of the interaction to cancel.
+ * @param apiVersion Which version of the API to use.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture cancel(
+ String id, Optional apiVersion,
+ Optional options) {
+ CancelInteractionByIdRequest request =
+ CancelInteractionByIdRequest
+ .builder()
+ .id(id)
+ .apiVersion(apiVersion)
+ .build();
+ AsyncRequestOperation operation
+ = new CancelInteractionById.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/AsyncWebhooks.java b/src/main/java/com/google/genai/gaos/AsyncWebhooks.java
new file mode 100644
index 00000000000..e969a130e36
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/AsyncWebhooks.java
@@ -0,0 +1,424 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.AsyncRequestOperation;
+
+import com.google.genai.gaos.models.operations.CreateWebhookRequest;
+import com.google.genai.gaos.models.operations.DeleteWebhookRequest;
+import com.google.genai.gaos.models.operations.GetWebhookRequest;
+import com.google.genai.gaos.models.operations.ListWebhooksRequest;
+import com.google.genai.gaos.models.operations.UpdateWebhookRequest;
+import com.google.genai.gaos.models.operations.async.CreateWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.async.CreateWebhookResponse;
+import com.google.genai.gaos.models.operations.async.DeleteWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.async.DeleteWebhookResponse;
+import com.google.genai.gaos.models.operations.async.GetWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.async.GetWebhookResponse;
+import com.google.genai.gaos.models.operations.async.ListWebhooksRequestBuilder;
+import com.google.genai.gaos.models.operations.async.ListWebhooksResponse;
+import com.google.genai.gaos.models.operations.async.PingWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.async.PingWebhookResponse;
+import com.google.genai.gaos.models.operations.async.RotateSigningSecretRequestBuilder;
+import com.google.genai.gaos.models.operations.async.RotateSigningSecretResponse;
+import com.google.genai.gaos.models.operations.async.UpdateWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.async.UpdateWebhookResponse;
+import com.google.genai.gaos.models.webhooks.PingWebhookRequest;
+import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest;
+import com.google.genai.gaos.models.webhooks.WebhookInput;
+import com.google.genai.gaos.models.webhooks.WebhookUpdate;
+import com.google.genai.gaos.operations.CreateWebhook;
+import com.google.genai.gaos.operations.DeleteWebhook;
+import com.google.genai.gaos.operations.GetWebhook;
+import com.google.genai.gaos.operations.ListWebhooks;
+import com.google.genai.gaos.operations.PingWebhook;
+import com.google.genai.gaos.operations.RotateSigningSecret;
+import com.google.genai.gaos.operations.UpdateWebhook;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import java.lang.Integer;
+import java.lang.String;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+
+@SuppressWarnings("all")
+public class AsyncWebhooks {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final Webhooks syncSDK;
+
+ AsyncWebhooks(Webhooks syncSDK, SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.syncSDK = syncSDK;
+ }
+
+ /**
+ * Switches to the sync SDK.
+ *
+ * @return The sync SDK
+ */
+ public Webhooks sync() {
+ return syncSDK;
+ }
+
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @return The async call builder
+ */
+ public CreateWebhookRequestBuilder create() {
+ return new CreateWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @param body A Webhook resource.
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture create(WebhookInput body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body A Webhook resource.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture create(
+ Optional apiVersion, WebhookInput body,
+ Optional options) {
+ CreateWebhookRequest request =
+ CreateWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new CreateWebhook.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @return The async call builder
+ */
+ public ListWebhooksRequestBuilder list() {
+ return new ListWebhooksRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture listDirect() {
+ return list(
+ Optional.empty(), Optional.empty(), Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param pageSize Optional. The maximum number of webhooks to return. The service may return fewer than
+ * this value. If unspecified, at most 50 webhooks will be returned.
+ * The maximum value is 1000.
+ * @param pageToken Optional. A page token, received from a previous `ListWebhooks` call.
+ * Provide this to retrieve the subsequent page.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture list(
+ Optional apiVersion, Optional pageSize,
+ Optional pageToken, Optional options) {
+ ListWebhooksRequest request =
+ ListWebhooksRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .pageSize(pageSize)
+ .pageToken(pageToken)
+ .build();
+ AsyncRequestOperation operation
+ = new ListWebhooks.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @return The async call builder
+ */
+ public GetWebhookRequestBuilder get() {
+ return new GetWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @param id Required. The ID of the webhook to retrieve.
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture get(String id) {
+ return get(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to retrieve.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture get(
+ Optional apiVersion, String id,
+ Optional options) {
+ GetWebhookRequest request =
+ GetWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ AsyncRequestOperation operation
+ = new GetWebhook.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @return The async call builder
+ */
+ public UpdateWebhookRequestBuilder update() {
+ return new UpdateWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @param id Required. The ID of the webhook to update.
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture update(String id) {
+ return update(
+ Optional.empty(), id, Optional.empty(),
+ Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to update.
+ * @param updateMask Optional. The list of fields to update.
+ * @param body
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture update(
+ Optional apiVersion, String id,
+ Optional updateMask, Optional extends WebhookUpdate> body,
+ Optional options) {
+ UpdateWebhookRequest request =
+ UpdateWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .updateMask(updateMask)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new UpdateWebhook.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @return The async call builder
+ */
+ public DeleteWebhookRequestBuilder delete() {
+ return new DeleteWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @param id Required. The ID of the webhook to delete.
+ * Format: `{webhook_id}`
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(String id) {
+ return delete(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to delete.
+ * Format: `{webhook_id}`
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture delete(
+ Optional apiVersion, String id,
+ Optional options) {
+ DeleteWebhookRequest request =
+ DeleteWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ AsyncRequestOperation operation
+ = new DeleteWebhook.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @return The async call builder
+ */
+ public RotateSigningSecretRequestBuilder rotateSigningSecret() {
+ return new RotateSigningSecretRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @param id Required. The ID of the webhook for which to generate a signing secret.
+ * Format: `{webhook_id}`
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture rotateSigningSecret(String id) {
+ return rotateSigningSecret(
+ Optional.empty(), id, Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook for which to generate a signing secret.
+ * Format: `{webhook_id}`
+ * @param body Request message for WebhookService.RotateSigningSecret.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture rotateSigningSecret(
+ Optional apiVersion, String id,
+ Optional extends RotateSigningSecretRequest> body, Optional options) {
+ com.google.genai.gaos.models.operations.RotateSigningSecretRequest request =
+ com.google.genai.gaos.models.operations.RotateSigningSecretRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new RotateSigningSecret.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @return The async call builder
+ */
+ public PingWebhookRequestBuilder ping() {
+ return new PingWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @param id Required. The ID of the webhook to ping.
+ * Format: `{webhook_id}`
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture ping(String id) {
+ return ping(
+ Optional.empty(), id, Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to ping.
+ * Format: `{webhook_id}`
+ * @param body Request message for WebhookService.PingWebhook.
+ * @param options additional options
+ * @return {@code CompletableFuture} - The async response
+ */
+ public CompletableFuture ping(
+ Optional apiVersion, String id,
+ Optional extends PingWebhookRequest> body, Optional options) {
+ com.google.genai.gaos.models.operations.PingWebhookRequest request =
+ com.google.genai.gaos.models.operations.PingWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .body(body)
+ .build();
+ AsyncRequestOperation operation
+ = new PingWebhook.Async(
+ sdkConfiguration, options, sdkConfiguration.retryScheduler(),
+ _headers);
+ return operation.doRequest(request)
+ .thenCompose(operation::handleResponse);
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/GenAI.java b/src/main/java/com/google/genai/gaos/GenAI.java
new file mode 100644
index 00000000000..459e14b2e87
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/GenAI.java
@@ -0,0 +1,284 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+
+package com.google.genai.gaos;
+
+import com.google.genai.gaos.utils.HTTPClient;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Hook.SdkInitData;
+import com.google.genai.gaos.utils.RetryConfig;
+import com.google.genai.gaos.utils.SpeakeasyHTTPClient;
+import com.google.genai.gaos.utils.Utils;
+import java.lang.String;
+import java.util.Map;
+import java.util.Optional;
+import java.util.function.Consumer;
+
+/**
+ * Gemini API: The Gemini Interactions API allows developers to build generative AI applications using
+ * Gemini models. Gemini is our most capable model, built from the ground up to be multimodal.
+ *
+ * It can generalize and seamlessly understand, operate across, and combine different types of
+ * information including language, images, audio, video, and code. You can use the Gemini API for use
+ * cases like reasoning across text and images, content generation, dialogue agents, summarization and
+ * classification systems, and more.
+ */
+@SuppressWarnings("all")
+public class GenAI {
+ private static final Headers _headers = Headers.EMPTY;
+
+
+ /**
+ * SERVERS contains the list of server urls available to the SDK.
+ */
+ public static final String[] SERVERS = {
+ /*
+ * Global Endpoint
+ */
+ "https://generativelanguage.googleapis.com",
+ };
+
+
+ private final Interactions interactions;
+
+
+ private final Webhooks webhooks;
+
+
+ private final Agents agents;
+
+
+ public Interactions interactions() {
+ return interactions;
+ }
+
+
+ public Webhooks webhooks() {
+ return webhooks;
+ }
+
+
+ public Agents agents() {
+ return agents;
+ }
+ private final AsyncGenAI asyncSDK;
+
+ /**
+ * The Builder class allows the configuration of a new instance of the SDK.
+ */
+ public static class Builder {
+
+ private final SDKConfiguration sdkConfiguration = new SDKConfiguration();
+ private String serverUrl;
+ private String server;
+
+
+ private Builder() {
+ }
+
+ /**
+ * Allows the default HTTP client to be overridden with a custom implementation.
+ *
+ * @param client The HTTP client to use for all requests.
+ * @return The builder instance.
+ */
+ public Builder client(HTTPClient client) {
+ this.sdkConfiguration.setClient(client);
+ return this;
+ }
+
+ /**
+ * Configures the SDK to use the provided security details.
+ *
+ * @param security The security details to use for all requests. Can be {@code null}.
+ * @return The builder instance.
+ */
+ public Builder security(com.google.genai.gaos.models.shared.Security security) {
+ this.sdkConfiguration.setSecuritySource(SecuritySource.of(security));
+ return this;
+ }
+
+ /**
+ * Configures the SDK to use a custom security source.
+ *
+ * @param securitySource The security source to use for all requests.
+ * @return The builder instance.
+ */
+ public Builder securitySource(SecuritySource securitySource) {
+ Utils.checkNotNull(securitySource, "securitySource");
+ this.sdkConfiguration.setSecuritySource(securitySource);
+ return this;
+ }
+
+ /**
+ * Overrides the default server URL.
+ *
+ * @param serverUrl The server URL to use for all requests.
+ * @return The builder instance.
+ */
+ public Builder serverURL(String serverUrl) {
+ this.serverUrl = serverUrl;
+ return this;
+ }
+
+ /**
+ * Overrides the default server URL with a templated URL populated with the provided parameters.
+ *
+ * @param serverUrl The server URL to use for all requests.
+ * @param params The parameters to use when templating the URL.
+ * @return The builder instance.
+ */
+ public Builder serverURL(String serverUrl, Map params) {
+ this.serverUrl = Utils.templateUrl(serverUrl, params);
+ return this;
+ }
+
+ /**
+ * Overrides the default server by index.
+ *
+ * @param serverIdx The server to use for all requests.
+ * @return The builder instance.
+ */
+ public Builder serverIndex(int serverIdx) {
+ this.sdkConfiguration.setServerIdx(serverIdx);
+ this.serverUrl= SERVERS[serverIdx];
+ return this;
+ }
+
+ /**
+ * Overrides the default configuration for retries
+ *
+ * @param retryConfig The retry configuration to use for all requests.
+ * @return The builder instance.
+ */
+ public Builder retryConfig(RetryConfig retryConfig) {
+ this.sdkConfiguration.setRetryConfig(Optional.of(retryConfig));
+ return this;
+ }
+
+ /**
+ * Enables debug logging for HTTP requests and responses, including JSON body content.
+ *
+ * Convenience method that calls {@link HTTPClient#enableDebugLogging(boolean)}.
+ * {@link SpeakeasyHTTPClient} honors this setting. If you are using a custom HTTP client,
+ * it is up to the custom client to honor this setting.
+ *
+ *
+ * @param enabled Whether to enable debug logging.
+ * @return The builder instance.
+ */
+ public Builder enableHTTPDebugLogging(boolean enabled) {
+ this.sdkConfiguration.client().enableDebugLogging(enabled);
+ return this;
+ }
+
+
+ /**
+ * Allows setting the apiVersion parameter for all supported operations.
+ *
+ * @param apiVersion The value to set.
+ * @return The builder instance.
+ */
+ public Builder apiVersion(String apiVersion) {
+ this.sdkConfiguration.globals.putParam("pathParam", "api_version", apiVersion);
+ return this;
+ }
+
+ /**
+ * Allows setting the apiRevision parameter for all supported operations.
+ *
+ * @param apiRevision The value to set.
+ * @return The builder instance.
+ */
+ public Builder apiRevision(String apiRevision) {
+ this.sdkConfiguration.globals.putParam("header", "Api-Revision", apiRevision);
+ return this;
+ }
+
+ /**
+ * Allows setting the userProject parameter for all supported operations.
+ *
+ * @param userProject The value to set.
+ * @return The builder instance.
+ */
+ public Builder userProject(String userProject) {
+ this.sdkConfiguration.globals.putParam("header", "x-goog-user-project", userProject);
+ return this;
+ }
+ // Visible for testing, may be accessed via reflection in tests
+ Builder _hooks(com.google.genai.gaos.utils.Hooks hooks) {
+ sdkConfiguration.setHooks(hooks);
+ return this;
+ }
+
+ // Visible for testing, may be accessed via reflection in tests
+ Builder _hooks(Consumer super com.google.genai.gaos.utils.Hooks> consumer) {
+ consumer.accept(sdkConfiguration.hooks());
+ return this;
+ }
+
+ /**
+ * Builds a new instance of the SDK.
+ *
+ * @return The SDK instance.
+ */
+ public GenAI build() {
+ if (serverUrl == null || serverUrl.isBlank()) {
+ serverUrl = SERVERS[0];
+ sdkConfiguration.setServerIdx(0);
+ }
+ sdkConfiguration.setServerUrl(serverUrl);
+ return new GenAI(sdkConfiguration);
+ }
+ }
+
+ /**
+ * Get a new instance of the SDK builder to configure a new instance of the SDK.
+ *
+ * @return The SDK builder instance.
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ private GenAI(SDKConfiguration sdkConfiguration) {
+ sdkConfiguration.initialize();
+ this.interactions = new Interactions(sdkConfiguration);
+ this.webhooks = new Webhooks(sdkConfiguration);
+ this.agents = new Agents(sdkConfiguration);
+ SdkInitData data = sdkConfiguration.hooks().sdkInit(
+ new SdkInitData(
+ sdkConfiguration.resolvedServerUrl(),
+ sdkConfiguration.client()));
+ sdkConfiguration.setServerUrl(data.baseUrl());
+ sdkConfiguration.setClient(data.client());
+ this.asyncSDK = new AsyncGenAI(this, sdkConfiguration);
+ }
+
+ /**
+ * Switches to the async SDK.
+ *
+ * @return The async SDK
+ */
+ public AsyncGenAI async() {
+ return asyncSDK;
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/Interactions.java b/src/main/java/com/google/genai/gaos/Interactions.java
new file mode 100644
index 00000000000..ba0bf8ff4fb
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/Interactions.java
@@ -0,0 +1,254 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.RequestOperation;
+
+import com.google.genai.gaos.models.operations.CancelInteractionByIdRequest;
+import com.google.genai.gaos.models.operations.CancelInteractionByIdRequestBuilder;
+import com.google.genai.gaos.models.operations.CancelInteractionByIdResponse;
+import com.google.genai.gaos.models.operations.CreateInteractionRequest;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
+import com.google.genai.gaos.models.operations.CreateInteractionRequestBuilder;
+import com.google.genai.gaos.models.operations.CreateInteractionResponse;
+import com.google.genai.gaos.models.operations.DeleteInteractionRequest;
+import com.google.genai.gaos.models.operations.DeleteInteractionRequestBuilder;
+import com.google.genai.gaos.models.operations.DeleteInteractionResponse;
+import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
+import com.google.genai.gaos.models.operations.GetInteractionByIdRequestBuilder;
+import com.google.genai.gaos.models.operations.GetInteractionByIdResponse;
+import com.google.genai.gaos.operations.CancelInteractionById;
+import com.google.genai.gaos.operations.CreateInteraction;
+import com.google.genai.gaos.operations.DeleteInteraction;
+import com.google.genai.gaos.operations.GetInteractionById;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import java.lang.String;
+import java.util.Optional;
+
+
+@SuppressWarnings("all")
+public class Interactions {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final AsyncInteractions asyncSDK;
+
+ Interactions(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.asyncSDK = new AsyncInteractions(this, sdkConfiguration);
+ }
+
+ /**
+ * Switches to the async SDK.
+ *
+ * @return The async SDK
+ */
+ public AsyncInteractions async() {
+ return asyncSDK;
+ }
+
+ /**
+ * Creating an interaction
+ *
+ * Creates a new interaction.
+ *
+ * @return The call builder
+ */
+ public CreateInteractionRequestBuilder create() {
+ return new CreateInteractionRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creating an interaction
+ *
+ *
Creates a new interaction.
+ *
+ * @param body The request body.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateInteractionResponse create(CreateInteractionRequestBody body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creating an interaction
+ *
+ *
Creates a new interaction.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body The request body.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateInteractionResponse create(
+ Optional apiVersion, CreateInteractionRequestBody body,
+ Optional options) {
+ CreateInteractionRequest request =
+ CreateInteractionRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new CreateInteraction.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Retrieving an interaction
+ *
+ * Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @return The call builder
+ */
+ public GetInteractionByIdRequestBuilder get() {
+ return new GetInteractionByIdRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Retrieving an interaction
+ *
+ *
Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @param request The request object containing all the parameters for the API call.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetInteractionByIdResponse get(GetInteractionByIdRequest request) {
+ return get(request, Optional.empty());
+ }
+
+ /**
+ * Retrieving an interaction
+ *
+ *
Retrieves the full details of a single interaction based on its `Interaction.id`.
+ *
+ * @param request The request object containing all the parameters for the API call.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetInteractionByIdResponse get(GetInteractionByIdRequest request, Optional options) {
+ RequestOperation operation
+ = new GetInteractionById.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Deleting an interaction
+ *
+ * Deletes the interaction by id.
+ *
+ * @return The call builder
+ */
+ public DeleteInteractionRequestBuilder delete() {
+ return new DeleteInteractionRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deleting an interaction
+ *
+ *
Deletes the interaction by id.
+ *
+ * @param id The unique identifier of the interaction to delete.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteInteractionResponse delete(String id) {
+ return delete(id, Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Deleting an interaction
+ *
+ *
Deletes the interaction by id.
+ *
+ * @param id The unique identifier of the interaction to delete.
+ * @param apiVersion Which version of the API to use.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteInteractionResponse delete(
+ String id, Optional apiVersion,
+ Optional options) {
+ DeleteInteractionRequest request =
+ DeleteInteractionRequest
+ .builder()
+ .id(id)
+ .apiVersion(apiVersion)
+ .build();
+ RequestOperation operation
+ = new DeleteInteraction.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Canceling an interaction
+ *
+ * Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @return The call builder
+ */
+ public CancelInteractionByIdRequestBuilder cancel() {
+ return new CancelInteractionByIdRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Canceling an interaction
+ *
+ *
Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @param id The unique identifier of the interaction to cancel.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CancelInteractionByIdResponse cancel(String id) {
+ return cancel(id, Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Canceling an interaction
+ *
+ *
Cancels an interaction by id. This only applies to background interactions that are still running.
+ *
+ * @param id The unique identifier of the interaction to cancel.
+ * @param apiVersion Which version of the API to use.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CancelInteractionByIdResponse cancel(
+ String id, Optional apiVersion,
+ Optional options) {
+ CancelInteractionByIdRequest request =
+ CancelInteractionByIdRequest
+ .builder()
+ .id(id)
+ .apiVersion(apiVersion)
+ .build();
+ RequestOperation operation
+ = new CancelInteractionById.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/SDKConfiguration.java b/src/main/java/com/google/genai/gaos/SDKConfiguration.java
new file mode 100644
index 00000000000..cc03a1449a8
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/SDKConfiguration.java
@@ -0,0 +1,163 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import com.google.genai.gaos.hooks.SDKHooks;
+import com.google.genai.gaos.utils.AsyncHooks;
+import com.google.genai.gaos.utils.Globals;
+import com.google.genai.gaos.utils.HTTPClient;
+import com.google.genai.gaos.utils.Hooks;
+import com.google.genai.gaos.utils.RetryConfig;
+import com.google.genai.gaos.utils.SpeakeasyHTTPClient;
+import com.google.genai.gaos.utils.Utils;
+import java.lang.String;
+import java.lang.SuppressWarnings;
+import java.util.Optional;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+@SuppressWarnings("all")
+public class SDKConfiguration {
+
+ private static final String LANGUAGE = "java";
+ public static final String OPENAPI_DOC_VERSION = "v1beta";
+ public static final String SDK_VERSION = "0.1.0";
+ public static final String GEN_VERSION = "2.913.3";
+ private static final String BASE_PACKAGE = "com.google.genai.gaos";
+ public static final String USER_AGENT =
+ String.format("speakeasy-sdk/%s %s %s %s %s",
+ LANGUAGE, SDK_VERSION, GEN_VERSION, OPENAPI_DOC_VERSION, BASE_PACKAGE);
+
+ private SecuritySource securitySource = SecuritySource.of(null);
+
+ public SecuritySource securitySource() {
+ return securitySource;
+ }
+
+ public void setSecuritySource(SecuritySource securitySource) {
+ Utils.checkNotNull(securitySource, "securitySource");
+ this.securitySource = securitySource;
+ }
+
+ private HTTPClient client = new SpeakeasyHTTPClient();
+
+ public HTTPClient client() {
+ return client;
+ }
+
+ public void setClient(HTTPClient client) {
+ Utils.checkNotNull(client, "client");
+ this.client = client;
+ }
+
+ private String serverUrl;
+
+ public String serverUrl() {
+ return serverUrl;
+ }
+
+ public void setServerUrl(String serverUrl) {
+ Utils.checkNotNull(serverUrl, "serverUrl");
+ this.serverUrl = trimFinalSlash(serverUrl);
+ }
+
+ private static String trimFinalSlash(String url) {
+ if (url == null) {
+ return null;
+ } else if (url.endsWith("/")) {
+ return url.substring(0, url.length() - 1);
+ } else {
+ return url;
+ }
+ }
+
+ public String resolvedServerUrl() {
+ return serverUrl;
+ }
+
+ private int serverIdx = 0;
+
+ public void setServerIdx(int serverIdx) {
+ this.serverIdx = serverIdx;
+ }
+
+ public int serverIdx() {
+ return serverIdx;
+ }
+
+
+ private Hooks _hooks = createHooks();
+
+ private static Hooks createHooks() {
+ Hooks hooks = new Hooks();
+ return hooks;
+ }
+
+ public Hooks hooks() {
+ return _hooks;
+ }
+
+ public void setHooks(Hooks hooks) {
+ this._hooks = hooks;
+ }
+
+ /**
+ * Initializes state (for example hooks).
+ **/
+ public void initialize() {
+ SDKHooks.initialize(_hooks);
+ SDKHooks.initialize(_asyncHooks);
+ }
+
+ @SuppressWarnings("serial")
+ public Globals globals = new Globals();
+
+ private Optional retryConfig = Optional.empty();
+
+ public Optional retryConfig() {
+ return retryConfig;
+ }
+
+ public void setRetryConfig(Optional retryConfig) {
+ Utils.checkNotNull(retryConfig, "retryConfig");
+ this.retryConfig = retryConfig;
+ }
+ private ScheduledExecutorService retryScheduler = Executors.newSingleThreadScheduledExecutor();
+
+ public ScheduledExecutorService retryScheduler() {
+ return retryScheduler;
+ }
+
+ public void setAsyncRetryScheduler(ScheduledExecutorService retryScheduler) {
+ Utils.checkNotNull(retryScheduler, "retryScheduler");
+ this.retryScheduler = retryScheduler;
+ }
+
+ private AsyncHooks _asyncHooks = new AsyncHooks();
+
+ public AsyncHooks asyncHooks() {
+ return _asyncHooks;
+ }
+
+ public void setAsyncHooks(AsyncHooks asyncHooks) {
+ Utils.checkNotNull(asyncHooks, "asyncHooks");
+ this._asyncHooks = asyncHooks;
+ }
+}
diff --git a/src/main/java/com/google/genai/gaos/SecuritySource.java b/src/main/java/com/google/genai/gaos/SecuritySource.java
new file mode 100644
index 00000000000..5efc5d3d5f8
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/SecuritySource.java
@@ -0,0 +1,44 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import com.google.genai.gaos.utils.HasSecurity;
+
+@SuppressWarnings("all")
+public interface SecuritySource {
+
+ HasSecurity getSecurity();
+
+ public static SecuritySource of(HasSecurity security) {
+ return new DefaultSecuritySource(security);
+ }
+
+ public static class DefaultSecuritySource implements SecuritySource {
+ private HasSecurity security;
+
+ public DefaultSecuritySource(HasSecurity security) {
+ this.security = security;
+ }
+
+ public HasSecurity getSecurity() {
+ return security;
+ }
+ }
+}
diff --git a/src/main/java/com/google/genai/gaos/Webhooks.java b/src/main/java/com/google/genai/gaos/Webhooks.java
new file mode 100644
index 00000000000..4335269b2e9
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/Webhooks.java
@@ -0,0 +1,405 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos;
+
+import static com.google.genai.gaos.operations.Operations.RequestOperation;
+
+import com.google.genai.gaos.models.operations.CreateWebhookRequest;
+import com.google.genai.gaos.models.operations.CreateWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.CreateWebhookResponse;
+import com.google.genai.gaos.models.operations.DeleteWebhookRequest;
+import com.google.genai.gaos.models.operations.DeleteWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.DeleteWebhookResponse;
+import com.google.genai.gaos.models.operations.GetWebhookRequest;
+import com.google.genai.gaos.models.operations.GetWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.GetWebhookResponse;
+import com.google.genai.gaos.models.operations.ListWebhooksRequest;
+import com.google.genai.gaos.models.operations.ListWebhooksRequestBuilder;
+import com.google.genai.gaos.models.operations.ListWebhooksResponse;
+import com.google.genai.gaos.models.operations.PingWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.PingWebhookResponse;
+import com.google.genai.gaos.models.operations.RotateSigningSecretRequestBuilder;
+import com.google.genai.gaos.models.operations.RotateSigningSecretResponse;
+import com.google.genai.gaos.models.operations.UpdateWebhookRequest;
+import com.google.genai.gaos.models.operations.UpdateWebhookRequestBuilder;
+import com.google.genai.gaos.models.operations.UpdateWebhookResponse;
+import com.google.genai.gaos.models.webhooks.PingWebhookRequest;
+import com.google.genai.gaos.models.webhooks.RotateSigningSecretRequest;
+import com.google.genai.gaos.models.webhooks.WebhookInput;
+import com.google.genai.gaos.models.webhooks.WebhookUpdate;
+import com.google.genai.gaos.operations.CreateWebhook;
+import com.google.genai.gaos.operations.DeleteWebhook;
+import com.google.genai.gaos.operations.GetWebhook;
+import com.google.genai.gaos.operations.ListWebhooks;
+import com.google.genai.gaos.operations.PingWebhook;
+import com.google.genai.gaos.operations.RotateSigningSecret;
+import com.google.genai.gaos.operations.UpdateWebhook;
+import com.google.genai.gaos.utils.Headers;
+import com.google.genai.gaos.utils.Options;
+import java.lang.Integer;
+import java.lang.String;
+import java.util.Optional;
+
+
+@SuppressWarnings("all")
+public class Webhooks {
+ private static final Headers _headers = Headers.EMPTY;
+ private final SDKConfiguration sdkConfiguration;
+ private final AsyncWebhooks asyncSDK;
+
+ Webhooks(SDKConfiguration sdkConfiguration) {
+ this.sdkConfiguration = sdkConfiguration;
+ this.asyncSDK = new AsyncWebhooks(this, sdkConfiguration);
+ }
+
+ /**
+ * Switches to the async SDK.
+ *
+ * @return The async SDK
+ */
+ public AsyncWebhooks async() {
+ return asyncSDK;
+ }
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @return The call builder
+ */
+ public CreateWebhookRequestBuilder create() {
+ return new CreateWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @param body A Webhook resource.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateWebhookResponse create(WebhookInput body) {
+ return create(Optional.empty(), body, Optional.empty());
+ }
+
+ /**
+ * Creates a new Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param body A Webhook resource.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public CreateWebhookResponse create(
+ Optional apiVersion, WebhookInput body,
+ Optional options) {
+ CreateWebhookRequest request =
+ CreateWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new CreateWebhook.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @return The call builder
+ */
+ public ListWebhooksRequestBuilder list() {
+ return new ListWebhooksRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListWebhooksResponse listDirect() {
+ return list(Optional.empty(), Optional.empty(), Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Lists all Webhooks.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param pageSize Optional. The maximum number of webhooks to return. The service may return fewer than
+ * this value. If unspecified, at most 50 webhooks will be returned.
+ * The maximum value is 1000.
+ * @param pageToken Optional. A page token, received from a previous `ListWebhooks` call.
+ * Provide this to retrieve the subsequent page.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public ListWebhooksResponse list(
+ Optional apiVersion, Optional pageSize,
+ Optional pageToken, Optional options) {
+ ListWebhooksRequest request =
+ ListWebhooksRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .pageSize(pageSize)
+ .pageToken(pageToken)
+ .build();
+ RequestOperation operation
+ = new ListWebhooks.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @return The call builder
+ */
+ public GetWebhookRequestBuilder get() {
+ return new GetWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @param id Required. The ID of the webhook to retrieve.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetWebhookResponse get(String id) {
+ return get(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Gets a specific Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to retrieve.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public GetWebhookResponse get(
+ Optional apiVersion, String id,
+ Optional options) {
+ GetWebhookRequest request =
+ GetWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ RequestOperation operation
+ = new GetWebhook.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @return The call builder
+ */
+ public UpdateWebhookRequestBuilder update() {
+ return new UpdateWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @param id Required. The ID of the webhook to update.
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public UpdateWebhookResponse update(String id) {
+ return update(Optional.empty(), id, Optional.empty(),
+ Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Updates an existing Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to update.
+ * @param updateMask Optional. The list of fields to update.
+ * @param body
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public UpdateWebhookResponse update(
+ Optional apiVersion, String id,
+ Optional updateMask, Optional extends WebhookUpdate> body,
+ Optional options) {
+ UpdateWebhookRequest request =
+ UpdateWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .updateMask(updateMask)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new UpdateWebhook.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @return The call builder
+ */
+ public DeleteWebhookRequestBuilder delete() {
+ return new DeleteWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @param id Required. The ID of the webhook to delete.
+ * Format: `{webhook_id}`
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteWebhookResponse delete(String id) {
+ return delete(Optional.empty(), id, Optional.empty());
+ }
+
+ /**
+ * Deletes a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to delete.
+ * Format: `{webhook_id}`
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public DeleteWebhookResponse delete(
+ Optional apiVersion, String id,
+ Optional options) {
+ DeleteWebhookRequest request =
+ DeleteWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .build();
+ RequestOperation operation
+ = new DeleteWebhook.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @return The call builder
+ */
+ public RotateSigningSecretRequestBuilder rotateSigningSecret() {
+ return new RotateSigningSecretRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @param id Required. The ID of the webhook for which to generate a signing secret.
+ * Format: `{webhook_id}`
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public RotateSigningSecretResponse rotateSigningSecret(String id) {
+ return rotateSigningSecret(Optional.empty(), id, Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Generates a new signing secret for a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook for which to generate a signing secret.
+ * Format: `{webhook_id}`
+ * @param body Request message for WebhookService.RotateSigningSecret.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public RotateSigningSecretResponse rotateSigningSecret(
+ Optional apiVersion, String id,
+ Optional extends RotateSigningSecretRequest> body, Optional options) {
+ com.google.genai.gaos.models.operations.RotateSigningSecretRequest request =
+ com.google.genai.gaos.models.operations.RotateSigningSecretRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new RotateSigningSecret.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @return The call builder
+ */
+ public PingWebhookRequestBuilder ping() {
+ return new PingWebhookRequestBuilder(sdkConfiguration);
+ }
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @param id Required. The ID of the webhook to ping.
+ * Format: `{webhook_id}`
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public PingWebhookResponse ping(String id) {
+ return ping(Optional.empty(), id, Optional.empty(),
+ Optional.empty());
+ }
+
+ /**
+ * Sends a ping event to a Webhook.
+ *
+ * @param apiVersion Which version of the API to use.
+ * @param id Required. The ID of the webhook to ping.
+ * Format: `{webhook_id}`
+ * @param body Request message for WebhookService.PingWebhook.
+ * @param options additional options
+ * @return The response from the API call
+ * @throws RuntimeException subclass if the API call fails
+ */
+ public PingWebhookResponse ping(
+ Optional apiVersion, String id,
+ Optional extends PingWebhookRequest> body, Optional options) {
+ com.google.genai.gaos.models.operations.PingWebhookRequest request =
+ com.google.genai.gaos.models.operations.PingWebhookRequest
+ .builder()
+ .apiVersion(apiVersion)
+ .id(id)
+ .body(body)
+ .build();
+ RequestOperation operation
+ = new PingWebhook.Sync(sdkConfiguration, options, _headers);
+ return operation.handleResponse(operation.doRequest(request));
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java
new file mode 100644
index 00000000000..692f34adbec
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/hooks/SDKHooks.java
@@ -0,0 +1,91 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+package com.google.genai.gaos.hooks;
+
+import com.google.genai.gaos.models.shared.Security;
+import com.google.genai.gaos.utils.HasSecurity;
+import com.google.genai.gaos.utils.Helpers;
+import java.net.http.HttpRequest;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+//
+// This file is written once by speakeasy code generation and
+// thereafter will not be overwritten by speakeasy updates. As a
+// consequence any customization of this class will be preserved.
+//
+
+@SuppressWarnings("all")
+public final class SDKHooks {
+
+ private SDKHooks() {
+ // prevent instantiation
+ }
+
+ public static void initialize(com.google.genai.gaos.utils.Hooks hooks) {
+ hooks.registerBeforeRequest(
+ (context, request) -> {
+ if (context.securitySource().isPresent()) {
+ HasSecurity hasSecurity = context.securitySource().get().getSecurity();
+ if (hasSecurity instanceof Security) {
+ Security security = (Security) hasSecurity;
+ HttpRequest.Builder builder = Helpers.copy(request);
+
+ if (security.defaultHeaders().isPresent()) {
+ for (Map.Entry entry : security.defaultHeaders().get().entrySet()) {
+ builder.setHeader(entry.getKey(), entry.getValue());
+ }
+ }
+ if (security.apiKey().isPresent()) {
+ builder.setHeader("x-goog-api-key", security.apiKey().get());
+ } else if (security.accessToken().isPresent()) {
+ builder.setHeader("Authorization", "Bearer " + security.accessToken().get());
+ }
+ return builder.build();
+ }
+ }
+ return request;
+ });
+ }
+
+ public static void initialize(com.google.genai.gaos.utils.AsyncHooks asyncHooks) {
+ asyncHooks.registerBeforeRequest(
+ (context, request) -> {
+ if (context.securitySource().isPresent()) {
+ HasSecurity hasSecurity = context.securitySource().get().getSecurity();
+ if (hasSecurity instanceof Security) {
+ Security security = (Security) hasSecurity;
+ HttpRequest.Builder builder = Helpers.copy(request);
+
+ if (security.defaultHeaders().isPresent()) {
+ for (Map.Entry entry : security.defaultHeaders().get().entrySet()) {
+ builder.setHeader(entry.getKey(), entry.getValue());
+ }
+ }
+ if (security.apiKey().isPresent()) {
+ builder.setHeader("x-goog-api-key", security.apiKey().get());
+ } else if (security.accessToken().isPresent()) {
+ builder.setHeader("Authorization", "Bearer " + security.accessToken().get());
+ }
+ return CompletableFuture.completedFuture(builder.build());
+ }
+ }
+ return CompletableFuture.completedFuture(request);
+ });
+ }
+
+}
diff --git a/src/main/java/com/google/genai/gaos/models/agents/Agent.java b/src/main/java/com/google/genai/gaos/models/agents/Agent.java
new file mode 100644
index 00000000000..c2d036cff03
--- /dev/null
+++ b/src/main/java/com/google/genai/gaos/models/agents/Agent.java
@@ -0,0 +1,465 @@
+/*
+* Copyright 2026 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
+*
+* http://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.
+*/
+
+/*
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
+ */
+package com.google.genai.gaos.models.agents;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.genai.gaos.utils.Utils;
+import java.lang.Override;
+import java.lang.String;
+import java.lang.SuppressWarnings;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Agent
+ *
+ * An agent definition for the CreateAgent API.
+ * This message is the target for annotation-parser-based JSON parsing.
+ * New format:
+ * {
+ * "id": "customer-sentinel",
+ * "base_agent": "",
+ * "system_instruction": "...",
+ * "base_environment": { "type": "remote", "sources": [...] },
+ * "tools": [ {"type": "code_execution"} ]
+ * }
+ */
+@SuppressWarnings("all")
+public class Agent {
+ /**
+ * The unique identifier for the agent.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("id")
+ private Optional id;
+
+ /**
+ * The base agent to extend.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("base_agent")
+ private Optional baseAgent;
+
+ /**
+ * System instruction for the agent.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("system_instruction")
+ private Optional systemInstruction;
+
+ /**
+ * Agent description for developers to quickly read and understand.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("description")
+ private Optional description;
+
+ /**
+ * The tools available to the agent.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("tools")
+ private Optional extends List> tools;
+
+ /**
+ * The environment configuration for the agent.
+ */
+ @JsonInclude(Include.NON_ABSENT)
+ @JsonProperty("base_environment")
+ private Optional extends BaseEnvironment> baseEnvironment;
+
+ @JsonCreator
+ public Agent(
+ @JsonProperty("id") Optional id,
+ @JsonProperty("base_agent") Optional baseAgent,
+ @JsonProperty("system_instruction") Optional systemInstruction,
+ @JsonProperty("description") Optional description,
+ @JsonProperty("tools") Optional extends List> tools,
+ @JsonProperty("base_environment") Optional extends BaseEnvironment> baseEnvironment) {
+ Utils.checkNotNull(id, "id");
+ Utils.checkNotNull(baseAgent, "baseAgent");
+ Utils.checkNotNull(systemInstruction, "systemInstruction");
+ Utils.checkNotNull(description, "description");
+ Utils.checkNotNull(tools, "tools");
+ Utils.checkNotNull(baseEnvironment, "baseEnvironment");
+ this.id = id;
+ this.baseAgent = baseAgent;
+ this.systemInstruction = systemInstruction;
+ this.description = description;
+ this.tools = tools;
+ this.baseEnvironment = baseEnvironment;
+ }
+
+ public Agent() {
+ this(Optional.empty(), Optional.empty(), Optional.empty(),
+ Optional.empty(), Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * The unique identifier for the agent.
+ */
+ @JsonIgnore
+ public Optional id() {
+ return id;
+ }
+
+ /**
+ * The base agent to extend.
+ */
+ @JsonIgnore
+ public Optional baseAgent() {
+ return baseAgent;
+ }
+
+ /**
+ * System instruction for the agent.
+ */
+ @JsonIgnore
+ public Optional systemInstruction() {
+ return systemInstruction;
+ }
+
+ /**
+ * Agent description for developers to quickly read and understand.
+ */
+ @JsonIgnore
+ public Optional description() {
+ return description;
+ }
+
+ /**
+ * The tools available to the agent.
+ */
+ @SuppressWarnings("unchecked")
+ @JsonIgnore
+ public Optional> tools() {
+ return (Optional>) tools;
+ }
+
+ /**
+ * The environment configuration for the agent.
+ */
+ @SuppressWarnings("unchecked")
+ @JsonIgnore
+ public Optional baseEnvironment() {
+ return (Optional) baseEnvironment;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * The unique identifier for the agent.
+ */
+ public Agent withId(String id) {
+ Utils.checkNotNull(id, "id");
+ this.id = Optional.ofNullable(id);
+ return this;
+ }
+
+
+ /**
+ * The unique identifier for the agent.
+ */
+ public Agent withId(Optional id) {
+ Utils.checkNotNull(id, "id");
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * The base agent to extend.
+ */
+ public Agent withBaseAgent(String baseAgent) {
+ Utils.checkNotNull(baseAgent, "baseAgent");
+ this.baseAgent = Optional.ofNullable(baseAgent);
+ return this;
+ }
+
+
+ /**
+ * The base agent to extend.
+ */
+ public Agent withBaseAgent(Optional baseAgent) {
+ Utils.checkNotNull(baseAgent, "baseAgent");
+ this.baseAgent = baseAgent;
+ return this;
+ }
+
+ /**
+ * System instruction for the agent.
+ */
+ public Agent withSystemInstruction(String systemInstruction) {
+ Utils.checkNotNull(systemInstruction, "systemInstruction");
+ this.systemInstruction = Optional.ofNullable(systemInstruction);
+ return this;
+ }
+
+
+ /**
+ * System instruction for the agent.
+ */
+ public Agent withSystemInstruction(Optional systemInstruction) {
+ Utils.checkNotNull(systemInstruction, "systemInstruction");
+ this.systemInstruction = systemInstruction;
+ return this;
+ }
+
+ /**
+ * Agent description for developers to quickly read and understand.
+ */
+ public Agent withDescription(String description) {
+ Utils.checkNotNull(description, "description");
+ this.description = Optional.ofNullable(description);
+ return this;
+ }
+
+
+ /**
+ * Agent description for developers to quickly read and understand.
+ */
+ public Agent withDescription(Optional description) {
+ Utils.checkNotNull(description, "description");
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * The tools available to the agent.
+ */
+ public Agent withTools(List