class

OpenAI::RealtimeSession

Inherits JSON::Serializable < Reference < Object

Realtime session object for the beta interface.

Constructors

new(id : String | Nil = nil, object : RealtimeSessionObject | Nil = nil, modalities : Hash(String, JSON::Any) | Nil = nil, model : RealtimeSessionModel | Nil = nil, instructions : String | Nil = nil, voice : VoiceIdsShared | Nil = nil, input_audio_format : RealtimeSessionInputAudioFormat | Nil = nil, output_audio_format : RealtimeSessionOutputAudioFormat | Nil = nil, input_audio_transcription : RealtimeSessionInputAudioTranscription | Nil = nil, turn_detection : RealtimeTurnDetection | Nil = nil, input_audio_noise_reduction : RealtimeSessionInputAudioNoiseReduction | Nil = nil, speed : Float64 | Nil = nil, tracing : RealtimeSessionTracing | Nil = nil, tools : Array(RealtimeFunctionTool) | Nil = nil, tool_choice : String | Nil = nil, temperature : Float64 | Nil = nil, max_response_output_tokens : RealtimeSessionMaxResponseOutputTokens | Nil = nil, expires_at : Int64 | Nil = nil, prompt : RealtimeSessionPrompt | Nil = nil, include_value : RealtimeSessionInclude | Nil = nil)
Source
new(*, __pull_for_json_serializable pull : JSON::PullParser)
Source

Instance methods

expires_at

Expiration timestamp for the session, in seconds since epoch.

Source
expires_at=(expires_at : Int64 | Nil)

Expiration timestamp for the session, in seconds since epoch.

Source
id

Unique identifier for the session that looks like sess_1234567890abcdef.

Source
id=(id : String | Nil)

Unique identifier for the session that looks like sess_1234567890abcdef.

Source
include_value
Source
include_value=(include_value : RealtimeSessionInclude | Nil)
Source
input_audio_format

The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel (mono), and little-endian byte order.

Source
input_audio_format=(input_audio_format : RealtimeSessionInputAudioFormat | Nil)

The format of input audio. Options are pcm16, g711_ulaw, or g711_alaw. For pcm16, input audio must be 16-bit PCM at a 24kHz sample rate, single channel (mono), and little-endian byte order.

Source
input_audio_noise_reduction

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.

Source
input_audio_noise_reduction=(input_audio_noise_reduction : RealtimeSessionInputAudioNoiseReduction | Nil)

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.

Source
input_audio_transcription
Source
input_audio_transcription=(input_audio_transcription : RealtimeSessionInputAudioTranscription | Nil)
Source
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.

Source
instructions=(instructions : String | Nil)

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.

Source
max_response_output_tokens

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 to inf.

Source
max_response_output_tokens=(max_response_output_tokens : RealtimeSessionMaxResponseOutputTokens | Nil)

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 to inf.

Source
modalities

The set of modalities the model can respond with. To disable audio, set this to ["text"].

Source
modalities=(modalities : Hash(String, JSON::Any) | Nil)

The set of modalities the model can respond with. To disable audio, set this to ["text"].

Source
model

The Realtime model used for this session.

Source
model=(model : RealtimeSessionModel | Nil)

The Realtime model used for this session.

Source
object

The object type. Always realtime.session.

Source
object=(object : RealtimeSessionObject | Nil)

The object type. Always realtime.session.

Source
output_audio_format

The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw. For pcm16, output audio is sampled at a rate of 24kHz.

Source
output_audio_format=(output_audio_format : RealtimeSessionOutputAudioFormat | Nil)

The format of output audio. Options are pcm16, g711_ulaw, or g711_alaw. For pcm16, output audio is sampled at a rate of 24kHz.

Source
prompt
Source
prompt=(prompt : RealtimeSessionPrompt | Nil)
Source
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.

Source
speed=(speed : Float64 | Nil)

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.

Source
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.

Source
temperature=(temperature : Float64 | Nil)

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.

Source
tool_choice

How the model chooses tools. Options are auto, none, required, or specify a function.

Source
tool_choice=(tool_choice : String | Nil)

How the model chooses tools. Options are auto, none, required, or specify a function.

Source
tools

Tools (functions) available to the model.

Source
tools=(tools : Array(RealtimeFunctionTool) | Nil)

Tools (functions) available to the model.

Source
tracing
Source
tracing=(tracing : RealtimeSessionTracing | Nil)
Source
turn_detection
Source
turn_detection=(turn_detection : RealtimeTurnDetection | Nil)
Source
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, and verse.

Source
voice=(voice : VoiceIdsShared | Nil)

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, and verse.

Source