Class SessionCreateParams
-
- All Implemented Interfaces:
-
com.openai.core.Params
public final class SessionCreateParams implements Params
Create an ephemeral API token for use in client-side applications with the Realtime API. Can be configured with the same session parameters as the
session.update
client event.It responds with a session object, plus a
client_secret
key which contains a usable ephemeral API token that can be used to authenticate browser clients for the Realtime API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
SessionCreateParams.Builder
A builder for SessionCreateParams.
public final class
SessionCreateParams.Body
Realtime session object configuration.
public final class
SessionCreateParams.ClientSecret
Configuration options for the generated client secret.
public final class
SessionCreateParams.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.public final class
SessionCreateParams.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.public final class
SessionCreateParams.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.public final class
SessionCreateParams.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
.public final class
SessionCreateParams.Modality
public final class
SessionCreateParams.Model
The Realtime model used for this session.
public final class
SessionCreateParams.OutputAudioFormat
The format of output audio. Options are
pcm16
,g711_ulaw
, org711_alaw
. Forpcm16
, output audio is sampled at a rate of 24kHz.public final class
SessionCreateParams.Tool
public final class
SessionCreateParams.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.public final class
SessionCreateParams.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 conjuction 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.public final class
SessionCreateParams.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
,fable
,onyx
,nova
,sage
,shimmer
, andverse
.
-
Method Summary
Modifier and Type Method Description final Optional<SessionCreateParams.ClientSecret>
clientSecret()
Configuration options for the generated client secret. final Optional<SessionCreateParams.InputAudioFormat>
inputAudioFormat()
The format of input audio. final Optional<SessionCreateParams.InputAudioNoiseReduction>
inputAudioNoiseReduction()
Configuration for input audio noise reduction. final Optional<SessionCreateParams.InputAudioTranscription>
inputAudioTranscription()
Configuration for input audio transcription, defaults to off and can be set to null
to turn off once on.final Optional<String>
instructions()
The default system instructions (i.e. final Optional<SessionCreateParams.MaxResponseOutputTokens>
maxResponseOutputTokens()
Maximum number of output tokens for a single assistant response, inclusive of tool calls. final Optional<List<SessionCreateParams.Modality>>
modalities()
The set of modalities the model can respond with. final Optional<SessionCreateParams.Model>
model()
The Realtime model used for this session. final Optional<SessionCreateParams.OutputAudioFormat>
outputAudioFormat()
The format of output audio. final Optional<Double>
speed()
The speed of the model's spoken response. final Optional<Double>
temperature()
Sampling temperature for the model, limited to 0.6, 1. final Optional<String>
toolChoice()
How the model chooses tools. final Optional<List<SessionCreateParams.Tool>>
tools()
Tools (functions) available to the model. final Optional<SessionCreateParams.Tracing>
tracing()
Configuration options for tracing. final Optional<SessionCreateParams.TurnDetection>
turnDetection()
Configuration for turn detection, ether Server VAD or Semantic VAD. final Optional<SessionCreateParams.Voice>
voice()
The voice the model uses to respond. final JsonField<SessionCreateParams.ClientSecret>
_clientSecret()
Returns the raw JSON value of clientSecret. final JsonField<SessionCreateParams.InputAudioFormat>
_inputAudioFormat()
Returns the raw JSON value of inputAudioFormat. final JsonField<SessionCreateParams.InputAudioNoiseReduction>
_inputAudioNoiseReduction()
Returns the raw JSON value of inputAudioNoiseReduction. final JsonField<SessionCreateParams.InputAudioTranscription>
_inputAudioTranscription()
Returns the raw JSON value of inputAudioTranscription. final JsonField<String>
_instructions()
Returns the raw JSON value of instructions. final JsonField<SessionCreateParams.MaxResponseOutputTokens>
_maxResponseOutputTokens()
Returns the raw JSON value of maxResponseOutputTokens. final JsonField<List<SessionCreateParams.Modality>>
_modalities()
Returns the raw JSON value of modalities. final JsonField<SessionCreateParams.Model>
_model()
Returns the raw JSON value of model. final JsonField<SessionCreateParams.OutputAudioFormat>
_outputAudioFormat()
Returns the raw JSON value of outputAudioFormat. final JsonField<Double>
_speed()
Returns the raw JSON value of speed. final JsonField<Double>
_temperature()
Returns the raw JSON value of temperature. final JsonField<String>
_toolChoice()
Returns the raw JSON value of toolChoice. final JsonField<List<SessionCreateParams.Tool>>
_tools()
Returns the raw JSON value of tools. final JsonField<SessionCreateParams.Tracing>
_tracing()
Returns the raw JSON value of tracing. final JsonField<SessionCreateParams.TurnDetection>
_turnDetection()
Returns the raw JSON value of turnDetection. final JsonField<SessionCreateParams.Voice>
_voice()
Returns the raw JSON value of voice. final Map<String, JsonValue>
_additionalBodyProperties()
final Headers
_additionalHeaders()
final QueryParams
_additionalQueryParams()
final SessionCreateParams.Builder
toBuilder()
final SessionCreateParams.Body
_body()
Headers
_headers()
The full set of headers in the parameters, including both fixed and additional headers. QueryParams
_queryParams()
The full set of query params in the parameters, including both fixed and additional query params. Boolean
equals(Object other)
Integer
hashCode()
String
toString()
final static SessionCreateParams
none()
final static SessionCreateParams.Builder
builder()
Returns a mutable builder for constructing an instance of SessionCreateParams. -
-
Method Detail
-
clientSecret
final Optional<SessionCreateParams.ClientSecret> clientSecret()
Configuration options for the generated client secret.
-
inputAudioFormat
final Optional<SessionCreateParams.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.
-
inputAudioNoiseReduction
final Optional<SessionCreateParams.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.
-
inputAudioTranscription
final Optional<SessionCreateParams.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.
-
instructions
final Optional<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.
-
maxResponseOutputTokens
final Optional<SessionCreateParams.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
.
-
modalities
final Optional<List<SessionCreateParams.Modality>> modalities()
The set of modalities the model can respond with. To disable audio, set this to "text".
-
model
final Optional<SessionCreateParams.Model> model()
The Realtime model used for this session.
-
outputAudioFormat
final Optional<SessionCreateParams.OutputAudioFormat> outputAudioFormat()
The format of output audio. Options are
pcm16
,g711_ulaw
, org711_alaw
. Forpcm16
, output audio is sampled at a rate of 24kHz.
-
speed
final Optional<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.
-
temperature
final Optional<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.
-
toolChoice
final Optional<String> toolChoice()
How the model chooses tools. Options are
auto
,none
,required
, or specify a function.
-
tools
final Optional<List<SessionCreateParams.Tool>> tools()
Tools (functions) available to the model.
-
tracing
final Optional<SessionCreateParams.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.
-
turnDetection
final Optional<SessionCreateParams.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 conjuction 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.
-
voice
final Optional<SessionCreateParams.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
,fable
,onyx
,nova
,sage
,shimmer
, andverse
.
-
_clientSecret
final JsonField<SessionCreateParams.ClientSecret> _clientSecret()
Returns the raw JSON value of clientSecret.
Unlike clientSecret, this method doesn't throw if the JSON field has an unexpected type.
-
_inputAudioFormat
final JsonField<SessionCreateParams.InputAudioFormat> _inputAudioFormat()
Returns the raw JSON value of inputAudioFormat.
Unlike inputAudioFormat, this method doesn't throw if the JSON field has an unexpected type.
-
_inputAudioNoiseReduction
final JsonField<SessionCreateParams.InputAudioNoiseReduction> _inputAudioNoiseReduction()
Returns the raw JSON value of inputAudioNoiseReduction.
Unlike inputAudioNoiseReduction, this method doesn't throw if the JSON field has an unexpected type.
-
_inputAudioTranscription
final JsonField<SessionCreateParams.InputAudioTranscription> _inputAudioTranscription()
Returns the raw JSON value of inputAudioTranscription.
Unlike inputAudioTranscription, this method doesn't throw if the JSON field has an unexpected type.
-
_instructions
final JsonField<String> _instructions()
Returns the raw JSON value of instructions.
Unlike instructions, this method doesn't throw if the JSON field has an unexpected type.
-
_maxResponseOutputTokens
final JsonField<SessionCreateParams.MaxResponseOutputTokens> _maxResponseOutputTokens()
Returns the raw JSON value of maxResponseOutputTokens.
Unlike maxResponseOutputTokens, this method doesn't throw if the JSON field has an unexpected type.
-
_modalities
final JsonField<List<SessionCreateParams.Modality>> _modalities()
Returns the raw JSON value of modalities.
Unlike modalities, this method doesn't throw if the JSON field has an unexpected type.
-
_model
final JsonField<SessionCreateParams.Model> _model()
Returns the raw JSON value of model.
Unlike model, this method doesn't throw if the JSON field has an unexpected type.
-
_outputAudioFormat
final JsonField<SessionCreateParams.OutputAudioFormat> _outputAudioFormat()
Returns the raw JSON value of outputAudioFormat.
Unlike outputAudioFormat, this method doesn't throw if the JSON field has an unexpected type.
-
_speed
final JsonField<Double> _speed()
Returns the raw JSON value of speed.
Unlike speed, this method doesn't throw if the JSON field has an unexpected type.
-
_temperature
final JsonField<Double> _temperature()
Returns the raw JSON value of temperature.
Unlike temperature, this method doesn't throw if the JSON field has an unexpected type.
-
_toolChoice
final JsonField<String> _toolChoice()
Returns the raw JSON value of toolChoice.
Unlike toolChoice, this method doesn't throw if the JSON field has an unexpected type.
-
_tools
final JsonField<List<SessionCreateParams.Tool>> _tools()
Returns the raw JSON value of tools.
Unlike tools, this method doesn't throw if the JSON field has an unexpected type.
-
_tracing
final JsonField<SessionCreateParams.Tracing> _tracing()
Returns the raw JSON value of tracing.
Unlike tracing, this method doesn't throw if the JSON field has an unexpected type.
-
_turnDetection
final JsonField<SessionCreateParams.TurnDetection> _turnDetection()
Returns the raw JSON value of turnDetection.
Unlike turnDetection, this method doesn't throw if the JSON field has an unexpected type.
-
_voice
final JsonField<SessionCreateParams.Voice> _voice()
Returns the raw JSON value of voice.
Unlike voice, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalBodyProperties
final Map<String, JsonValue> _additionalBodyProperties()
-
_additionalHeaders
final Headers _additionalHeaders()
-
_additionalQueryParams
final QueryParams _additionalQueryParams()
-
toBuilder
final SessionCreateParams.Builder toBuilder()
-
_body
final SessionCreateParams.Body _body()
-
_headers
Headers _headers()
The full set of headers in the parameters, including both fixed and additional headers.
-
_queryParams
QueryParams _queryParams()
The full set of query params in the parameters, including both fixed and additional query params.
-
none
final static SessionCreateParams none()
-
builder
final static SessionCreateParams.Builder builder()
Returns a mutable builder for constructing an instance of SessionCreateParams.
-
-
-
-