Class GeminiInteractionsClient
java.lang.Object
io.github.glaforge.gemini.interactions.GeminiInteractionsClient
Client for the Gemini Interactions API.
This client allows you to interact with the Gemini API to create interactions, retrieve past interactions, and more.
Example usage:
GeminiInteractionsClient client = GeminiInteractionsClient.builder()
.apiKey(System.getenv("GEMINI_API_KEY"))
.build();
InteractionParams.Request request = ModelInteractionParams.builder()
.model("gemini-2.5-flash")
.input("Hello, world!")
.build();
Interaction interaction = client.create(request);
System.out.println(interaction.outputs().get(0).text());
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder for the GeminiInteractionsClient.Cancels an interaction by ID.create(InteractionParams.Request request) Creates a new interaction.voidDeletes an interaction by ID.Retrieves an interaction by ID.Retrieves an interaction by ID, optionally including the original input.stream(InteractionParams.Request request) Creates a streaming interaction.
-
Method Details
-
builder
Creates a new builder for the GeminiInteractionsClient.- Returns:
- A new builder.
-
create
Creates a new interaction.- Parameters:
request- The interaction request parameters (Model or Agent).- Returns:
- The created Interaction.
- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.- See Also:
-
stream
Creates a streaming interaction.- Parameters:
request- The interaction request parameters (Model or Agent).- Returns:
- A Stream of Events.
- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.
-
get
Retrieves an interaction by ID.- Parameters:
id- The interaction ID.- Returns:
- The Interaction.
- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.- See Also:
-
get
Retrieves an interaction by ID, optionally including the original input.- Parameters:
id- The interaction ID.includeInput- Whether to include the input in the response.- Returns:
- The Interaction.
- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.- See Also:
-
delete
Deletes an interaction by ID.- Parameters:
id- The interaction ID.- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.- See Also:
-
cancel
Cancels an interaction by ID.- Parameters:
id- The interaction ID.- Returns:
- The updated Interaction (status should be cancelled).
- Throws:
GeminiInteractionsException- If the API request fails or an error occurs.- See Also:
-