Package com.google.genai.gaos
Class Interactions
java.lang.Object
com.google.genai.gaos.Interactions
-
Method Summary
Modifier and TypeMethodDescriptionasync()Switches to the async SDK.cancel()Cancels an interaction by id.Cancels an interaction by id.Cancels an interaction by id.create()Creates a new interaction.create(CreateInteractionRequest request) Creates a new interaction.Creates a new interaction.create(CreateInteractionRequestBody body, boolean automaticContinuation) Creates a new interaction.create(CreateInteractionRequest request, Options options) Creates a new interaction.create(String apiVersion, CreateInteractionRequestBody body, Options options) Creates a new interaction.delete()Deletes the interaction by id.Deletes the interaction by id.Deletes the interaction by id.get()Retrieves the full details of a single interaction based on its `Interaction.id`.get(GetInteractionByIdRequest request) Retrieves the full details of a single interaction based on its `Interaction.id`.get(GetInteractionByIdRequest request, Options options) Retrieves the full details of a single interaction based on its `Interaction.id`.
-
Method Details
-
async
Switches to the async SDK.- Returns:
- The async SDK
-
create
Creates a new interaction.- Returns:
- The call builder
-
create
Creates a new interaction.- Parameters:
body- The request body.- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
create
public CreateInteractionResponse create(@Nonnull CreateInteractionRequestBody body, boolean automaticContinuation) Creates a new interaction.- Parameters:
body- The request body.automaticContinuation- Whether to automatically continue decoding across continuation hops; seecreate(CreateInteractionRequest, Options).- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
create
public CreateInteractionResponse create(@Nullable String apiVersion, @Nonnull CreateInteractionRequestBody body, @Nullable Options options) Creates a new interaction.- Parameters:
apiVersion- API version for request routing.body- The request body.options- additional options- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
create
Creates a new interaction.- Parameters:
request- The request object containing all the parameters for the API call.- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
create
public CreateInteractionResponse create(@Nonnull CreateInteractionRequest request, @Nullable Options options) Creates a new interaction.Automatic continuation.
request.automaticContinuation()defaults totrue. When enabled, the SDK automatically resumes decoding across multiple continuation hops whenever a response or stream stops at the per-request decode token limit (status='requires_continuation'with acontinuation_token) until the interaction completes, reachesincomplete(e.g.max_output_tokens), requires action, or fails. PassautomaticContinuation(false)to disable; the server response is then returned as-is (field for field, continuation fields included) so the caller can resume manually, and a one-time warning is logged if it stopped atrequires_continuation.- For
stream=true, events from all continuation hops are yielded sequentially on the returnedCreateInteractionResponse.events()stream, verbatim: each hop's owninteraction.createdandinteraction.completed(with statusrequires_continuation) are included, so checkstatusoninteraction.completedrather than treating the first one as the end. - For
stream=false, each continuation hop is a separate interaction on the server that only contains that hop's output. The SDK merges the hops into oneInteraction:stepsare concatenated in hop order,usagetoken counts are summed across hops (withusage.initial_input_tokensset to the first hop's input tokens), and all other fields (id,status, ...) come from the final hop. The final hop'sidcan be passed asprevious_interaction_idto continue the conversation.continuation_idslists the ids of every hop in order (the last one isid); note thatget(id)anddelete(id)act on a single hop.previous_interaction_id,createdandinputcome from the first hop. - With
store=true(the default), each continuation hop sends the hop that issued thecontinuation_tokenasprevious_interaction_idand omitsinput(the server already has it). Withstore=false, the originalinputis resent with the token. - Client-side continuation is skipped for
background=trueand agent interactions (agent/agent_config), whose loops are managed by the server.background=truewithautomaticContinuation(false)is rejected with anIllegalArgumentExceptionbefore any request is sent. - Timeouts:
request.timeout()is a wall-clock budget for the wholecreate()call. Once it runs out no further hop starts (and no further stream event is read) and the call stops withContinuationInterruptedException(see Errors) so the work so far can be resumed. Per-request HTTP timeouts (e.g.HttpOptions.timeouton the client) andRetryConfigapply to each hop separately: transient errors on a continuation hop retry that hop using the latestcontinuation_tokenwithout restarting from the initial request. - Billing note: with
background=false, each continuation hop re-prefills the conversation and generated prefix, so input tokens are billed on every hop (and summed inusage.total_input_tokens). If an unrecoverable error occurs after one or more hops have completed, those completed hops are still billed. For server-managed continuation without client-side hop loops, usebackground=true(withstore=true). - Errors: a failure on the first request is thrown as usual. A failure after progress
(a later hop, or a stream after a resumable checkpoint) throws
ContinuationInterruptedException(with the failure as cause) carryingcontinuationToken,interactionIdandcontinuationIds, pluspartialInteraction(the completed hops merged, forstream=false), so the output already produced is not lost and the call can be resumed manually. Running out of the per-call timeout after progress is reported the same way.
- Parameters:
request- The request object containing all the parameters for the API call.options- additional options- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
- For
-
delete
Deletes the interaction by id.- Returns:
- The call builder
-
delete
Deletes the interaction by id.- Parameters:
id- Required. The name of the interaction to delete.- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
delete
public DeleteInteractionResponse delete(@Nullable String apiVersion, @Nonnull String id, @Nullable Options options) Deletes the interaction by id.- Parameters:
apiVersion- API version for request routing.id- Required. The name of the interaction to delete.options- additional options- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
get
Retrieves the full details of a single interaction based on its `Interaction.id`.- Returns:
- The call builder
-
get
Retrieves the full details of a single interaction based on its `Interaction.id`.- Parameters:
request- The request object containing all the parameters for the API call.- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
get
public GetInteractionByIdResponse get(@Nonnull GetInteractionByIdRequest request, @Nullable Options options) Retrieves the full details of a single interaction based on its `Interaction.id`.- Parameters:
request- The request object containing all the parameters for the API call.options- additional options- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
cancel
Cancels an interaction by id. This only applies to background interactions that are still running.- Returns:
- The call builder
-
cancel
Cancels an interaction by id. This only applies to background interactions that are still running.- Parameters:
id- Required. The name of the interaction to cancel.- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-
cancel
public CancelInteractionByIdResponse cancel(@Nullable String apiVersion, @Nonnull String id, @Nullable Options options) Cancels an interaction by id. This only applies to background interactions that are still running.- Parameters:
apiVersion- API version for request routing.id- Required. The name of the interaction to cancel.options- additional options- Returns:
- The response from the API call
- Throws:
RuntimeException- subclass if the API call fails
-