Class RealtimeSession.Builder
-
- All Implemented Interfaces:
public final class RealtimeSession.Builder
A builder for RealtimeSession.
-
-
Method Summary
-
-
Method Detail
-
id
final RealtimeSession.Builder id(String id)
Unique identifier for the session that looks like
sess_1234567890abcdef
.
-
id
final RealtimeSession.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.
-
expiresAt
final RealtimeSession.Builder expiresAt(Long expiresAt)
Expiration timestamp for the session, in seconds since epoch.
-
expiresAt
final RealtimeSession.Builder expiresAt(JsonField<Long> expiresAt)
Sets Builder.expiresAt to an arbitrary JSON value.
You should usually call Builder.expiresAt with a well-typed Long value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
include
final RealtimeSession.Builder include(List<RealtimeSession.Include> include)
Additional fields to include in server outputs.
item.input_audio_transcription.logprobs
: Include logprobs for input audio transcription.
-
include
final RealtimeSession.Builder include(Optional<List<RealtimeSession.Include>> include)
Alias for calling Builder.include with
include.orElse(null)
.
-
include
final RealtimeSession.Builder include(JsonField<List<RealtimeSession.Include>> include)
Sets Builder.include to an arbitrary JSON value.
You should usually call Builder.include with a well-typed
List<Include>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addInclude
final RealtimeSession.Builder addInclude(RealtimeSession.Include include)
Adds a single Include to Builder.include.
-
inputAudioFormat
final RealtimeSession.Builder inputAudioFormat(RealtimeSession.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 RealtimeSession.Builder inputAudioFormat(JsonField<RealtimeSession.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 RealtimeSession.Builder inputAudioNoiseReduction(RealtimeSession.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 RealtimeSession.Builder inputAudioNoiseReduction(JsonField<RealtimeSession.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 RealtimeSession.Builder inputAudioTranscription(AudioTranscription 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 RealtimeSession.Builder inputAudioTranscription(Optional<AudioTranscription> inputAudioTranscription)
Alias for calling Builder.inputAudioTranscription with
inputAudioTranscription.orElse(null)
.
-
inputAudioTranscription
final RealtimeSession.Builder inputAudioTranscription(JsonField<AudioTranscription> inputAudioTranscription)
Sets Builder.inputAudioTranscription to an arbitrary JSON value.
You should usually call Builder.inputAudioTranscription with a well-typed AudioTranscription value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
instructions
final RealtimeSession.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 RealtimeSession.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 RealtimeSession.Builder maxResponseOutputTokens(RealtimeSession.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 RealtimeSession.Builder maxResponseOutputTokens(JsonField<RealtimeSession.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 RealtimeSession.Builder maxResponseOutputTokens(Long integer)
Alias for calling maxResponseOutputTokens with
MaxResponseOutputTokens.ofInteger(integer)
.
-
maxResponseOutputTokensInf
final RealtimeSession.Builder maxResponseOutputTokensInf()
Alias for calling maxResponseOutputTokens with
MaxResponseOutputTokens.ofInf()
.
-
modalities
final RealtimeSession.Builder modalities(List<RealtimeSession.Modality> modalities)
The set of modalities the model can respond with. To disable audio, set this to "text".
-
modalities
final RealtimeSession.Builder modalities(JsonField<List<RealtimeSession.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 RealtimeSession.Builder addModality(RealtimeSession.Modality modality)
Adds a single Modality to modalities.
-
model
final RealtimeSession.Builder model(RealtimeSession.Model model)
The Realtime model used for this session.
-
model
final RealtimeSession.Builder model(JsonField<RealtimeSession.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.
-
object_
final RealtimeSession.Builder object_(RealtimeSession.Object object_)
The object type. Always
realtime.session
.
-
object_
final RealtimeSession.Builder object_(JsonField<RealtimeSession.Object> object_)
Sets Builder.object_ to an arbitrary JSON value.
You should usually call Builder.object_ with a well-typed Object value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
outputAudioFormat
final RealtimeSession.Builder outputAudioFormat(RealtimeSession.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 RealtimeSession.Builder outputAudioFormat(JsonField<RealtimeSession.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.
-
prompt
final RealtimeSession.Builder prompt(ResponsePrompt prompt)
Reference to a prompt template and its variables. Learn more.
-
prompt
final RealtimeSession.Builder prompt(Optional<ResponsePrompt> prompt)
Alias for calling Builder.prompt with
prompt.orElse(null)
.
-
prompt
final RealtimeSession.Builder prompt(JsonField<ResponsePrompt> prompt)
Sets Builder.prompt to an arbitrary JSON value.
You should usually call Builder.prompt with a well-typed ResponsePrompt value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
speed
final RealtimeSession.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 RealtimeSession.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 RealtimeSession.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 RealtimeSession.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 RealtimeSession.Builder toolChoice(String toolChoice)
How the model chooses tools. Options are
auto
,none
,required
, or specify a function.
-
toolChoice
final RealtimeSession.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 RealtimeSession.Builder tools(List<RealtimeFunctionTool> tools)
Tools (functions) available to the model.
-
tools
final RealtimeSession.Builder tools(JsonField<List<RealtimeFunctionTool>> tools)
Sets Builder.tools to an arbitrary JSON value.
You should usually call Builder.tools with a well-typed
List<RealtimeFunctionTool>
value instead. This method is primarily for setting the field to an undocumented or not yet supported value.
-
addTool
final RealtimeSession.Builder addTool(RealtimeFunctionTool tool)
Adds a single RealtimeFunctionTool to tools.
-
tracing
final RealtimeSession.Builder tracing(RealtimeSession.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 RealtimeSession.Builder tracing(Optional<RealtimeSession.Tracing> tracing)
Alias for calling Builder.tracing with
tracing.orElse(null)
.
-
tracing
final RealtimeSession.Builder tracing(JsonField<RealtimeSession.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 RealtimeSession.Builder tracing(RealtimeSession.Tracing.TracingConfiguration configuration)
Alias for calling tracing with
Tracing.ofConfiguration(configuration)
.
-
tracingAuto
final RealtimeSession.Builder tracingAuto()
Alias for calling tracing with
Tracing.ofAuto()
.
-
turnDetection
final RealtimeSession.Builder turnDetection(RealtimeSession.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 RealtimeSession.Builder turnDetection(Optional<RealtimeSession.TurnDetection> turnDetection)
Alias for calling Builder.turnDetection with
turnDetection.orElse(null)
.
-
turnDetection
final RealtimeSession.Builder turnDetection(JsonField<RealtimeSession.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.
-
turnDetection
final RealtimeSession.Builder turnDetection(RealtimeSession.TurnDetection.ServerVad serverVad)
Alias for calling turnDetection with
TurnDetection.ofServerVad(serverVad)
.
-
turnDetection
final RealtimeSession.Builder turnDetection(RealtimeSession.TurnDetection.SemanticVad semanticVad)
Alias for calling turnDetection with
TurnDetection.ofSemanticVad(semanticVad)
.
-
voice
final RealtimeSession.Builder voice(RealtimeSession.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 RealtimeSession.Builder voice(JsonField<RealtimeSession.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 RealtimeSession.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 RealtimeSession.Builder additionalProperties(Map<String, JsonValue> additionalProperties)
-
putAdditionalProperty
final RealtimeSession.Builder putAdditionalProperty(String key, JsonValue value)
-
putAllAdditionalProperties
final RealtimeSession.Builder putAllAdditionalProperties(Map<String, JsonValue> additionalProperties)
-
removeAdditionalProperty
final RealtimeSession.Builder removeAdditionalProperty(String key)
-
removeAllAdditionalProperties
final RealtimeSession.Builder removeAllAdditionalProperties(Set<String> keys)
-
build
final RealtimeSession build()
Returns an immutable instance of RealtimeSession.
Further updates to this Builder will not mutate the returned instance.
-
-
-
-