Class Session.Builder
-
- All Implemented Interfaces:
public final class Session.Builder
A builder for Session.
-
-
Method Summary
Modifier and Type Method Description final Session.Builder
id(String id)
Unique identifier for the session that looks like sess_1234567890abcdef
.final Session.Builder
id(JsonField<String> id)
Sets Builder.id to an arbitrary JSON value. final Session.Builder
inputAudioFormat(Session.InputAudioFormat inputAudioFormat)
The format of input audio. final Session.Builder
inputAudioFormat(JsonField<Session.InputAudioFormat> inputAudioFormat)
Sets Builder.inputAudioFormat to an arbitrary JSON value. final Session.Builder
inputAudioNoiseReduction(Session.InputAudioNoiseReduction inputAudioNoiseReduction)
Configuration for input audio noise reduction. final Session.Builder
inputAudioNoiseReduction(JsonField<Session.InputAudioNoiseReduction> inputAudioNoiseReduction)
Sets Builder.inputAudioNoiseReduction to an arbitrary JSON value. final Session.Builder
inputAudioTranscription(Session.InputAudioTranscription inputAudioTranscription)
Configuration for input audio transcription, defaults to off and can be set to null
to turn off once on.final Session.Builder
inputAudioTranscription(JsonField<Session.InputAudioTranscription> inputAudioTranscription)
Sets Builder.inputAudioTranscription to an arbitrary JSON value. final Session.Builder
instructions(String instructions)
The default system instructions (i.e. final Session.Builder
instructions(JsonField<String> instructions)
Sets Builder.instructions to an arbitrary JSON value. final Session.Builder
maxResponseOutputTokens(Session.MaxResponseOutputTokens maxResponseOutputTokens)
Maximum number of output tokens for a single assistant response, inclusive of tool calls. final Session.Builder
maxResponseOutputTokens(JsonField<Session.MaxResponseOutputTokens> maxResponseOutputTokens)
Sets Builder.maxResponseOutputTokens to an arbitrary JSON value. final Session.Builder
maxResponseOutputTokens(Long integer)
Alias for calling maxResponseOutputTokens with MaxResponseOutputTokens.ofInteger(integer)
.final Session.Builder
maxResponseOutputTokensInf()
Alias for calling maxResponseOutputTokens with MaxResponseOutputTokens.ofInf()
.final Session.Builder
modalities(List<Session.Modality> modalities)
The set of modalities the model can respond with. final Session.Builder
modalities(JsonField<List<Session.Modality>> modalities)
Sets Builder.modalities to an arbitrary JSON value. final Session.Builder
addModality(Session.Modality modality)
Adds a single Modality to modalities. final Session.Builder
model(Session.Model model)
The Realtime model used for this session. final Session.Builder
model(JsonField<Session.Model> model)
Sets Builder.model to an arbitrary JSON value. final Session.Builder
outputAudioFormat(Session.OutputAudioFormat outputAudioFormat)
The format of output audio. final Session.Builder
outputAudioFormat(JsonField<Session.OutputAudioFormat> outputAudioFormat)
Sets Builder.outputAudioFormat to an arbitrary JSON value. final Session.Builder
speed(Double speed)
The speed of the model's spoken response. final Session.Builder
speed(JsonField<Double> speed)
Sets Builder.speed to an arbitrary JSON value. final Session.Builder
temperature(Double temperature)
Sampling temperature for the model, limited to 0.6, 1. final Session.Builder
temperature(JsonField<Double> temperature)
Sets Builder.temperature to an arbitrary JSON value. final Session.Builder
toolChoice(String toolChoice)
How the model chooses tools. final Session.Builder
toolChoice(JsonField<String> toolChoice)
Sets Builder.toolChoice to an arbitrary JSON value. final Session.Builder
tools(List<Session.Tool> tools)
Tools (functions) available to the model. final Session.Builder
tools(JsonField<List<Session.Tool>> tools)
Sets Builder.tools to an arbitrary JSON value. final Session.Builder
addTool(Session.Tool tool)
Adds a single Tool to tools. final Session.Builder
tracing(Session.Tracing tracing)
Configuration options for tracing. final Session.Builder
tracing(JsonField<Session.Tracing> tracing)
Sets Builder.tracing to an arbitrary JSON value. final Session.Builder
tracing(Session.Tracing.TracingConfiguration configuration)
Alias for calling tracing with Tracing.ofConfiguration(configuration)
.final Session.Builder
tracingAuto()
Alias for calling tracing with Tracing.ofAuto()
.final Session.Builder
turnDetection(Session.TurnDetection turnDetection)
Configuration for turn detection, ether Server VAD or Semantic VAD. final Session.Builder
turnDetection(JsonField<Session.TurnDetection> turnDetection)
Sets Builder.turnDetection to an arbitrary JSON value. final Session.Builder
voice(Session.Voice voice)
The voice the model uses to respond. final Session.Builder
voice(JsonField<Session.Voice> voice)
Sets Builder.voice to an arbitrary JSON value. final Session.Builder
voice(String value)
Sets voice to an arbitrary String. final Session.Builder
additionalProperties(Map<String, JsonValue> additionalProperties)
final Session.Builder
putAdditionalProperty(String key, JsonValue value)
final Session.Builder
putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
final Session.Builder
removeAdditionalProperty(String key)
final Session.Builder
removeAllAdditionalProperties(Set<String> keys)
final Session
build()
Returns an immutable instance of Session. -
-
Method Detail
-
id
final Session.Builder id(String id)
Unique identifier for the session that looks like
sess_1234567890abcdef
.
-
id
final Session.Builder id(JsonField<String> id)
Sets Builder.id to an arbitrary JSON value.
You should usually call Builder.id with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
inputAudioFormat
final Session.Builder inputAudioFormat(Session.InputAudioFormat inputAudioFormat)
The format of input audio. Options are
pcm16
,g711_ulaw
, org711_alaw
. Forpcm16
, input audio must be 16-bit PCM at a 24kHz sample rate, single channel (mono), and little-endian byte order.
-
inputAudioFormat
final Session.Builder inputAudioFormat(JsonField<Session.InputAudioFormat> inputAudioFormat)
Sets Builder.inputAudioFormat to an arbitrary JSON value.
You should usually call Builder.inputAudioFormat with a well-typed InputAudioFormat value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
inputAudioNoiseReduction
final Session.Builder inputAudioNoiseReduction(Session.InputAudioNoiseReduction inputAudioNoiseReduction)
Configuration for input audio noise reduction. This can be set to
null
to turn off. Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model. Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
-
inputAudioNoiseReduction
final Session.Builder inputAudioNoiseReduction(JsonField<Session.InputAudioNoiseReduction> inputAudioNoiseReduction)
Sets Builder.inputAudioNoiseReduction to an arbitrary JSON value.
You should usually call Builder.inputAudioNoiseReduction with a well-typed InputAudioNoiseReduction value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
inputAudioTranscription
final Session.Builder inputAudioTranscription(Session.InputAudioTranscription inputAudioTranscription)
Configuration for input audio transcription, defaults to off and can be set to
null
to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through the /audio/transcriptions endpoint and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.
-
inputAudioTranscription
final Session.Builder inputAudioTranscription(JsonField<Session.InputAudioTranscription> inputAudioTranscription)
Sets Builder.inputAudioTranscription to an arbitrary JSON value.
You should usually call Builder.inputAudioTranscription with a well-typed InputAudioTranscription value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
instructions
final Session.Builder instructions(String instructions)
The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.
Note that the server sets default instructions which will be used if this field is not set and are visible in the
session.created
event at the start of the session.
-
instructions
final Session.Builder instructions(JsonField<String> instructions)
Sets Builder.instructions to an arbitrary JSON value.
You should usually call Builder.instructions with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxResponseOutputTokens
final Session.Builder maxResponseOutputTokens(Session.MaxResponseOutputTokens maxResponseOutputTokens)
Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
inf
for the maximum available tokens for a given model. Defaults toinf
.
-
maxResponseOutputTokens
final Session.Builder maxResponseOutputTokens(JsonField<Session.MaxResponseOutputTokens> maxResponseOutputTokens)
Sets Builder.maxResponseOutputTokens to an arbitrary JSON value.
You should usually call Builder.maxResponseOutputTokens with a well-typed MaxResponseOutputTokens value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
maxResponseOutputTokens
final Session.Builder maxResponseOutputTokens(Long integer)
Alias for calling maxResponseOutputTokens with
MaxResponseOutputTokens.ofInteger(integer)
.
-
maxResponseOutputTokensInf
final Session.Builder maxResponseOutputTokensInf()
Alias for calling maxResponseOutputTokens with
MaxResponseOutputTokens.ofInf()
.
-
modalities
final Session.Builder modalities(List<Session.Modality> modalities)
The set of modalities the model can respond with. To disable audio, set this to "text".
-
modalities
final Session.Builder modalities(JsonField<List<Session.Modality>> modalities)
Sets Builder.modalities to an arbitrary JSON value.
You should usually call Builder.modalities with a well-typed
List<Modality>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addModality
final Session.Builder addModality(Session.Modality modality)
Adds a single Modality to modalities.
-
model
final Session.Builder model(Session.Model model)
The Realtime model used for this session.
-
model
final Session.Builder model(JsonField<Session.Model> model)
Sets Builder.model to an arbitrary JSON value.
You should usually call Builder.model with a well-typed Model value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
outputAudioFormat
final Session.Builder outputAudioFormat(Session.OutputAudioFormat outputAudioFormat)
The format of output audio. Options are
pcm16
,g711_ulaw
, org711_alaw
. Forpcm16
, output audio is sampled at a rate of 24kHz.
-
outputAudioFormat
final Session.Builder outputAudioFormat(JsonField<Session.OutputAudioFormat> outputAudioFormat)
Sets Builder.outputAudioFormat to an arbitrary JSON value.
You should usually call Builder.outputAudioFormat with a well-typed OutputAudioFormat value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
speed
final Session.Builder speed(Double speed)
The speed of the model's spoken response. 1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.
-
speed
final Session.Builder speed(JsonField<Double> speed)
Sets Builder.speed to an arbitrary JSON value.
You should usually call Builder.speed with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
temperature
final Session.Builder temperature(Double temperature)
Sampling temperature for the model, limited to 0.6, 1.2. For audio models a temperature of 0.8 is highly recommended for best performance.
-
temperature
final Session.Builder temperature(JsonField<Double> temperature)
Sets Builder.temperature to an arbitrary JSON value.
You should usually call Builder.temperature with a well-typed Double value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
toolChoice
final Session.Builder toolChoice(String toolChoice)
How the model chooses tools. Options are
auto
,none
,required
, or specify a function.
-
toolChoice
final Session.Builder toolChoice(JsonField<String> toolChoice)
Sets Builder.toolChoice to an arbitrary JSON value.
You should usually call Builder.toolChoice with a well-typed String value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
tools
final Session.Builder tools(List<Session.Tool> tools)
Tools (functions) available to the model.
-
tools
final Session.Builder tools(JsonField<List<Session.Tool>> tools)
Sets Builder.tools to an arbitrary JSON value.
You should usually call Builder.tools with a well-typed
List<Tool>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addTool
final Session.Builder addTool(Session.Tool tool)
-
tracing
final Session.Builder tracing(Session.Tracing tracing)
Configuration options for tracing. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified.
auto
will create a trace for the session with default values for the workflow name, group id, and metadata.
-
tracing
final Session.Builder tracing(JsonField<Session.Tracing> tracing)
Sets Builder.tracing to an arbitrary JSON value.
You should usually call Builder.tracing with a well-typed Tracing value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
tracing
final Session.Builder tracing(Session.Tracing.TracingConfiguration configuration)
Alias for calling tracing with
Tracing.ofConfiguration(configuration)
.
-
tracingAuto
final Session.Builder tracingAuto()
Alias for calling tracing with
Tracing.ofAuto()
.
-
turnDetection
final Session.Builder turnDetection(Session.TurnDetection turnDetection)
Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to
null
to turn off, in which case the client must manually trigger model response. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech. Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with "uhhm", the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.
-
turnDetection
final Session.Builder turnDetection(JsonField<Session.TurnDetection> turnDetection)
Sets Builder.turnDetection to an arbitrary JSON value.
You should usually call Builder.turnDetection with a well-typed TurnDetection value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
voice
final Session.Builder voice(Session.Voice voice)
The voice the model uses to respond. Voice cannot be changed during the session once the model has responded with audio at least once. Current voice options are
alloy
,ash
,ballad
,coral
,echo
,sage
,shimmer
, andverse
.
-
voice
final Session.Builder voice(JsonField<Session.Voice> voice)
Sets Builder.voice to an arbitrary JSON value.
You should usually call Builder.voice with a well-typed Voice value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
voice
final Session.Builder voice(String value)
Sets voice to an arbitrary String.
You should usually call voice with a well-typed Voice constant instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
additionalProperties
final Session.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
putAdditionalProperty
final Session.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final Session.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final Session.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final Session.Builder removeAllAdditionalProperties(Set<String> keys)
-
-
-
-