public class SessionService.SessionServiceClient : ClientBase<SessionService.SessionServiceClient>Reference documentation and code samples for the Gemini Enterprise for Customer Experience v1beta API class SessionService.SessionServiceClient.
Client for SessionService
Inheritance
object > ClientBase > ClientBaseSessionServiceSessionServiceClient > SessionService.SessionServiceClientNamespace
Google.Cloud.Ces.V1BetaAssembly
Google.Cloud.Ces.V1Beta.dll
Constructors
SessionServiceClient()
protected SessionServiceClient()Protected parameterless constructor to allow creation of test doubles.
SessionServiceClient(CallInvoker)
public SessionServiceClient(CallInvoker callInvoker)Creates a new client for SessionService that uses a custom CallInvoker.
| Parameter | |
|---|---|
| Name | Description |
callInvoker |
CallInvokerThe callInvoker to use to make remote calls. |
SessionServiceClient(ChannelBase)
public SessionServiceClient(ChannelBase channel)Creates a new client for SessionService
| Parameter | |
|---|---|
| Name | Description |
channel |
ChannelBaseThe channel to use to make remote calls. |
SessionServiceClient(ClientBaseConfiguration)
protected SessionServiceClient(ClientBase.ClientBaseConfiguration configuration)Protected constructor to allow creation of configured clients.
| Parameter | |
|---|---|
| Name | Description |
configuration |
ClientBaseClientBaseConfigurationThe client configuration. |
Methods
BidiRunSession(CallOptions)
public virtual AsyncDuplexStreamingCall<BidiSessionClientMessage, BidiSessionServerMessage> BidiRunSession(CallOptions options)Establishes a bidirectional streaming connection with the CES agent. The agent processes continuous multimodal inputs (e.g., text, audio) and generates real-time multimodal output streams.
--- Client Request Stream --- The client streams requests in the following order:
Initialization: The first message must contain [SessionConfig][google.cloud.ces.v1beta.BidiSessionClientMessage.config]. For audio sessions, this should also include [InputAudioConfig][google.cloud.ces.v1beta.SessionConfig.input_audio_config] and [OutputAudioConfig][google.cloud.ces.v1beta.SessionConfig.output_audio_config] to define audio processing and synthesis parameters.
Interaction: Subsequent messages stream [SessionInput][google.cloud.ces.v1beta.BidiSessionClientMessage.realtime_input] containing real-time user input data.
Termination: The client should half-close the stream when there is no more user input. It should also half-close upon receiving [EndSession][google.cloud.ces.v1beta.BidiSessionServerMessage.end_session] or [GoAway][google.cloud.ces.v1beta.BidiSessionServerMessage.go_away] from the agent.
--- Server Response Stream --- For each interaction turn, the agent streams messages in the following sequence:
Speech Recognition (First N messages): Contains [RecognitionResult][google.cloud.ces.v1beta.BidiSessionServerMessage.recognition_result] representing the concatenated user speech segments captured so far. This is only populated for audio sessions.
Response (Next M messages): Contains [SessionOutput][google.cloud.ces.v1beta.BidiSessionServerMessage.session_output] delivering the agent's response in various modalities (e.g., text, audio).
Turn Completion (Final message of the turn): Contains [SessionOutput][google.cloud.ces.v1beta.BidiSessionServerMessage.session_output] with [turn_completed][google.cloud.ces.v1beta.SessionOutput.turn_completed] set to true. This signals the end of the current turn and includes [DiagnosticInfo][google.cloud.ces.v1beta.SessionOutput.diagnostic_info] with execution details.
--- Audio Best Practices ---
Streaming: Stream [audio data][google.cloud.ces.v1beta.SessionInput.audio] CONTINUOUSLY, even during silence. Recommended chunk size: 40-120ms (balances latency vs. efficiency).
Playback & Interruption: Play [audio responses][google.cloud.ces.v1beta.SessionOutput.audio] upon receipt. Stop playback immediately if an [InterruptionSignal][google.cloud.ces.v1beta.BidiSessionServerMessage.interruption_signal] is received (e.g., user barge-in or new agent response).
| Parameter | |
|---|---|
| Name | Description |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncDuplexStreamingCallBidiSessionClientMessageBidiSessionServerMessage |
The call object. |
BidiRunSession(Metadata, DateTime?, CancellationToken)
public virtual AsyncDuplexStreamingCall<BidiSessionClientMessage, BidiSessionServerMessage> BidiRunSession(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Establishes a bidirectional streaming connection with the CES agent. The agent processes continuous multimodal inputs (e.g., text, audio) and generates real-time multimodal output streams.
--- Client Request Stream --- The client streams requests in the following order:
Initialization: The first message must contain [SessionConfig][google.cloud.ces.v1beta.BidiSessionClientMessage.config]. For audio sessions, this should also include [InputAudioConfig][google.cloud.ces.v1beta.SessionConfig.input_audio_config] and [OutputAudioConfig][google.cloud.ces.v1beta.SessionConfig.output_audio_config] to define audio processing and synthesis parameters.
Interaction: Subsequent messages stream [SessionInput][google.cloud.ces.v1beta.BidiSessionClientMessage.realtime_input] containing real-time user input data.
Termination: The client should half-close the stream when there is no more user input. It should also half-close upon receiving [EndSession][google.cloud.ces.v1beta.BidiSessionServerMessage.end_session] or [GoAway][google.cloud.ces.v1beta.BidiSessionServerMessage.go_away] from the agent.
--- Server Response Stream --- For each interaction turn, the agent streams messages in the following sequence:
Speech Recognition (First N messages): Contains [RecognitionResult][google.cloud.ces.v1beta.BidiSessionServerMessage.recognition_result] representing the concatenated user speech segments captured so far. This is only populated for audio sessions.
Response (Next M messages): Contains [SessionOutput][google.cloud.ces.v1beta.BidiSessionServerMessage.session_output] delivering the agent's response in various modalities (e.g., text, audio).
Turn Completion (Final message of the turn): Contains [SessionOutput][google.cloud.ces.v1beta.BidiSessionServerMessage.session_output] with [turn_completed][google.cloud.ces.v1beta.SessionOutput.turn_completed] set to true. This signals the end of the current turn and includes [DiagnosticInfo][google.cloud.ces.v1beta.SessionOutput.diagnostic_info] with execution details.
--- Audio Best Practices ---
Streaming: Stream [audio data][google.cloud.ces.v1beta.SessionInput.audio] CONTINUOUSLY, even during silence. Recommended chunk size: 40-120ms (balances latency vs. efficiency).
Playback & Interruption: Play [audio responses][google.cloud.ces.v1beta.SessionOutput.audio] upon receipt. Stop playback immediately if an [InterruptionSignal][google.cloud.ces.v1beta.BidiSessionServerMessage.interruption_signal] is received (e.g., user barge-in or new agent response).
| Parameters | |
|---|---|
| Name | Description |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncDuplexStreamingCallBidiSessionClientMessageBidiSessionServerMessage |
The call object. |
CancelAssistantTurn(CancelAssistantTurnRequest, CallOptions)
public virtual CancelAssistantTurnResponse CancelAssistantTurn(CancelAssistantTurnRequest request, CallOptions options)Cancels the assistant session's in-flight turn, if any: the explicit user stop for a turn running detached from any stream. A cancel landing on a task that does not host the turn preempts it through the session turn epoch instead, ending it within one lease renewal.
| Parameters | |
|---|---|
| Name | Description |
request |
CancelAssistantTurnRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
CancelAssistantTurnResponse |
The response received from the server. |
CancelAssistantTurn(CancelAssistantTurnRequest, Metadata, DateTime?, CancellationToken)
public virtual CancelAssistantTurnResponse CancelAssistantTurn(CancelAssistantTurnRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Cancels the assistant session's in-flight turn, if any: the explicit user stop for a turn running detached from any stream. A cancel landing on a task that does not host the turn preempts it through the session turn epoch instead, ending it within one lease renewal.
| Parameters | |
|---|---|
| Name | Description |
request |
CancelAssistantTurnRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
CancelAssistantTurnResponse |
The response received from the server. |
CancelAssistantTurnAsync(CancelAssistantTurnRequest, CallOptions)
public virtual AsyncUnaryCall<CancelAssistantTurnResponse> CancelAssistantTurnAsync(CancelAssistantTurnRequest request, CallOptions options)Cancels the assistant session's in-flight turn, if any: the explicit user stop for a turn running detached from any stream. A cancel landing on a task that does not host the turn preempts it through the session turn epoch instead, ending it within one lease renewal.
| Parameters | |
|---|---|
| Name | Description |
request |
CancelAssistantTurnRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallCancelAssistantTurnResponse |
The call object. |
CancelAssistantTurnAsync(CancelAssistantTurnRequest, Metadata, DateTime?, CancellationToken)
public virtual AsyncUnaryCall<CancelAssistantTurnResponse> CancelAssistantTurnAsync(CancelAssistantTurnRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Cancels the assistant session's in-flight turn, if any: the explicit user stop for a turn running detached from any stream. A cancel landing on a task that does not host the turn preempts it through the session turn epoch instead, ending it within one lease renewal.
| Parameters | |
|---|---|
| Name | Description |
request |
CancelAssistantTurnRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallCancelAssistantTurnResponse |
The call object. |
CreateLocationsClient()
public virtual Locations.LocationsClient CreateLocationsClient()Creates a new instance of Locations.LocationsClient using the same call invoker as this client.
| Returns | |
|---|---|
| Type | Description |
LocationsLocationsClient |
A new Locations.LocationsClient for the same target as this client. |
GenerateOnboardingSuggestions(GenerateOnboardingSuggestionsRequest, CallOptions)
public virtual GenerateOnboardingSuggestionsResponse GenerateOnboardingSuggestions(GenerateOnboardingSuggestionsRequest request, CallOptions options)Generates personalized onboarding suggestions for the Arc zero state: classifies the requesting user (new / exploring / returning) from their assistant-session history in the app and returns suggestion chips (resume a session, continue work, or start something new) to render before any message is sent.
| Parameters | |
|---|---|
| Name | Description |
request |
GenerateOnboardingSuggestionsRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
GenerateOnboardingSuggestionsResponse |
The response received from the server. |
GenerateOnboardingSuggestions(GenerateOnboardingSuggestionsRequest, Metadata, DateTime?, CancellationToken)
public virtual GenerateOnboardingSuggestionsResponse GenerateOnboardingSuggestions(GenerateOnboardingSuggestionsRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Generates personalized onboarding suggestions for the Arc zero state: classifies the requesting user (new / exploring / returning) from their assistant-session history in the app and returns suggestion chips (resume a session, continue work, or start something new) to render before any message is sent.
| Parameters | |
|---|---|
| Name | Description |
request |
GenerateOnboardingSuggestionsRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
GenerateOnboardingSuggestionsResponse |
The response received from the server. |
GenerateOnboardingSuggestionsAsync(GenerateOnboardingSuggestionsRequest, CallOptions)
public virtual AsyncUnaryCall<GenerateOnboardingSuggestionsResponse> GenerateOnboardingSuggestionsAsync(GenerateOnboardingSuggestionsRequest request, CallOptions options)Generates personalized onboarding suggestions for the Arc zero state: classifies the requesting user (new / exploring / returning) from their assistant-session history in the app and returns suggestion chips (resume a session, continue work, or start something new) to render before any message is sent.
| Parameters | |
|---|---|
| Name | Description |
request |
GenerateOnboardingSuggestionsRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallGenerateOnboardingSuggestionsResponse |
The call object. |
GenerateOnboardingSuggestionsAsync(GenerateOnboardingSuggestionsRequest, Metadata, DateTime?, CancellationToken)
public virtual AsyncUnaryCall<GenerateOnboardingSuggestionsResponse> GenerateOnboardingSuggestionsAsync(GenerateOnboardingSuggestionsRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Generates personalized onboarding suggestions for the Arc zero state: classifies the requesting user (new / exploring / returning) from their assistant-session history in the app and returns suggestion chips (resume a session, continue work, or start something new) to render before any message is sent.
| Parameters | |
|---|---|
| Name | Description |
request |
GenerateOnboardingSuggestionsRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallGenerateOnboardingSuggestionsResponse |
The call object. |
NewInstance(ClientBaseConfiguration)
protected override SessionService.SessionServiceClient NewInstance(ClientBase.ClientBaseConfiguration configuration)Creates a new instance of client from given ClientBaseConfiguration.
| Parameter | |
|---|---|
| Name | Description |
configuration |
ClientBaseClientBaseConfiguration |
| Returns | |
|---|---|
| Type | Description |
SessionServiceSessionServiceClient |
|
RunSession(RunSessionRequest, CallOptions)
public virtual RunSessionResponse RunSession(RunSessionRequest request, CallOptions options)Initiates a single-turn interaction with the CES agent within a session.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
RunSessionResponse |
The response received from the server. |
RunSession(RunSessionRequest, Metadata, DateTime?, CancellationToken)
public virtual RunSessionResponse RunSession(RunSessionRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Initiates a single-turn interaction with the CES agent within a session.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
RunSessionResponse |
The response received from the server. |
RunSessionAsync(RunSessionRequest, CallOptions)
public virtual AsyncUnaryCall<RunSessionResponse> RunSessionAsync(RunSessionRequest request, CallOptions options)Initiates a single-turn interaction with the CES agent within a session.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallRunSessionResponse |
The call object. |
RunSessionAsync(RunSessionRequest, Metadata, DateTime?, CancellationToken)
public virtual AsyncUnaryCall<RunSessionResponse> RunSessionAsync(RunSessionRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Initiates a single-turn interaction with the CES agent within a session.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncUnaryCallRunSessionResponse |
The call object. |
StreamChatAiAssistant(StreamChatAiAssistantRequest, CallOptions)
public virtual AsyncServerStreamingCall<StreamChatAiAssistantResponse> StreamChatAiAssistant(StreamChatAiAssistantRequest request, CallOptions options)Runs Arc, the AI assistant, for the specified assistant session in a streaming fashion.
| Parameters | |
|---|---|
| Name | Description |
request |
StreamChatAiAssistantRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncServerStreamingCallStreamChatAiAssistantResponse |
The call object. |
StreamChatAiAssistant(StreamChatAiAssistantRequest, Metadata, DateTime?, CancellationToken)
public virtual AsyncServerStreamingCall<StreamChatAiAssistantResponse> StreamChatAiAssistant(StreamChatAiAssistantRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Runs Arc, the AI assistant, for the specified assistant session in a streaming fashion.
| Parameters | |
|---|---|
| Name | Description |
request |
StreamChatAiAssistantRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncServerStreamingCallStreamChatAiAssistantResponse |
The call object. |
StreamRunSession(RunSessionRequest, CallOptions)
public virtual AsyncServerStreamingCall<RunSessionResponse> StreamRunSession(RunSessionRequest request, CallOptions options)Initiates a single-turn interaction with the CES agent. Uses server-side streaming to deliver incremental results and partial responses as they are generated.
By default, complete responses (e.g., messages from callbacks or full LLM responses) are sent to the client as soon as they are available. To enable streaming individual text chunks directly from the model, set [enable_text_streaming][google.cloud.ces.v1beta.SessionConfig.enable_text_streaming] to true.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
options |
CallOptionsThe options for the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncServerStreamingCallRunSessionResponse |
The call object. |
StreamRunSession(RunSessionRequest, Metadata, DateTime?, CancellationToken)
public virtual AsyncServerStreamingCall<RunSessionResponse> StreamRunSession(RunSessionRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default)Initiates a single-turn interaction with the CES agent. Uses server-side streaming to deliver incremental results and partial responses as they are generated.
By default, complete responses (e.g., messages from callbacks or full LLM responses) are sent to the client as soon as they are available. To enable streaming individual text chunks directly from the model, set [enable_text_streaming][google.cloud.ces.v1beta.SessionConfig.enable_text_streaming] to true.
| Parameters | |
|---|---|
| Name | Description |
request |
RunSessionRequestThe request to send to the server. |
headers |
MetadataThe initial metadata to send with the call. This parameter is optional. |
deadline |
System.DateTimeAn optional deadline for the call. The call will be cancelled if deadline is hit. |
cancellationToken |
CancellationTokenAn optional token for canceling the call. |
| Returns | |
|---|---|
| Type | Description |
AsyncServerStreamingCallRunSessionResponse |
The call object. |