Table of Contents

Class SessionConfiguration

Namespace
OpenAI.Realtime
Assembly
OpenAI-DotNet.dll
public class SessionConfiguration
Inheritance
SessionConfiguration
Inherited Members

Constructors

SessionConfiguration()

public SessionConfiguration()

SessionConfiguration(Model, Modality, Voice, string, RealtimeAudioFormat, RealtimeAudioFormat, Model, IVoiceActivityDetectionSettings, IEnumerable<Tool>, string, float?, int?, int?)

[Obsolete("use new ctor overload")]
public SessionConfiguration(Model model, Modality modalities, Voice voice, string instructions, RealtimeAudioFormat inputAudioFormat, RealtimeAudioFormat outputAudioFormat, Model transcriptionModel, IVoiceActivityDetectionSettings turnDetectionSettings, IEnumerable<Tool> tools, string toolChoice, float? temperature, int? maxResponseOutputTokens, int? expiresAfter)

Parameters

model Model
modalities Modality
voice Voice
instructions string
inputAudioFormat RealtimeAudioFormat
outputAudioFormat RealtimeAudioFormat
transcriptionModel Model
turnDetectionSettings IVoiceActivityDetectionSettings
tools IEnumerable<Tool>
toolChoice string
temperature float?
maxResponseOutputTokens int?
expiresAfter int?

SessionConfiguration(Model, Modality, Voice, string, RealtimeAudioFormat, RealtimeAudioFormat, InputAudioTranscriptionSettings, IVoiceActivityDetectionSettings, IEnumerable<Tool>, string, float?, int?, int?, NoiseReductionSettings, float?, Prompt)

public SessionConfiguration(Model model, Modality modalities = Modality.Text | Modality.Audio, Voice voice = null, string instructions = null, RealtimeAudioFormat inputAudioFormat = RealtimeAudioFormat.PCM16, RealtimeAudioFormat outputAudioFormat = RealtimeAudioFormat.PCM16, InputAudioTranscriptionSettings inputAudioTranscriptionSettings = null, IVoiceActivityDetectionSettings turnDetectionSettings = null, IEnumerable<Tool> tools = null, string toolChoice = null, float? temperature = null, int? maxResponseOutputTokens = null, int? expiresAfter = null, NoiseReductionSettings inputAudioNoiseSettings = null, float? speed = null, Prompt prompt = null)

Parameters

model Model
modalities Modality
voice Voice
instructions string
inputAudioFormat RealtimeAudioFormat
outputAudioFormat RealtimeAudioFormat
inputAudioTranscriptionSettings InputAudioTranscriptionSettings
turnDetectionSettings IVoiceActivityDetectionSettings
tools IEnumerable<Tool>
toolChoice string
temperature float?
maxResponseOutputTokens int?
expiresAfter int?
inputAudioNoiseSettings NoiseReductionSettings
speed float?
prompt Prompt

Properties

ClientSecret

Ephemeral key returned by the API.

[JsonInclude]
[JsonPropertyName("client_secret")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ClientSecret ClientSecret { get; }

Property Value

ClientSecret

InputAudioFormat

The format of input audio.Options are pcm16, g711_ulaw, or g711_alaw.

[JsonInclude]
[JsonPropertyName("input_audio_format")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter<RealtimeAudioFormat>))]
public RealtimeAudioFormat InputAudioFormat { get; }

Property Value

RealtimeAudioFormat

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.

[JsonInclude]
[JsonPropertyName("input_audio_noise_reduction")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public NoiseReductionSettings InputAudioNoiseReduction { get; }

Property Value

NoiseReductionSettings

InputAudioTranscriptionSettings

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 and should be treated as rough guidance rather than the representation understood by the model.

[JsonInclude]
[JsonPropertyName("input_audio_transcription")]
public InputAudioTranscriptionSettings InputAudioTranscriptionSettings { get; }

Property Value

InputAudioTranscriptionSettings

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.

[JsonInclude]
[JsonPropertyName("instructions")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Instructions { get; }

Property Value

string

Remarks

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

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.

[JsonInclude]
[JsonPropertyName("max_response_output_tokens")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public object MaxResponseOutputTokens { get; }

Property Value

object

Modalities

The set of modalities the model can respond with.

[JsonInclude]
[JsonPropertyName("modalities")]
[JsonConverter(typeof(ModalityConverter))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public Modality Modalities { get; }

Property Value

Modality

Model

The Realtime model used for this session.

[JsonInclude]
[JsonPropertyName("model")]
public string Model { get; }

Property Value

string

OutputAudioFormat

The format of output audio.Options are pcm16, g711_ulaw, or g711_alaw.

[JsonInclude]
[JsonPropertyName("output_audio_format")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[JsonConverter(typeof(JsonStringEnumConverter<RealtimeAudioFormat>))]
public RealtimeAudioFormat OutputAudioFormat { get; }

Property Value

RealtimeAudioFormat

Prompt

Reference to a prompt template and its variables.

[JsonInclude]
[JsonPropertyName("prompt")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Prompt Prompt { get; }

Property Value

Prompt

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.

[JsonInclude]
[JsonPropertyName("speed")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public float? Speed { get; }

Property Value

float?

Temperature

Sampling temperature for the model, limited to[0.6, 1.2]. Defaults to 0.8.

[JsonInclude]
[JsonPropertyName("temperature")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public float? Temperature { get; }

Property Value

float?

ToolChoice

How the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.

[JsonInclude]
[JsonPropertyName("tool_choice")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object ToolChoice { get; }

Property Value

object

Tools

Tools (functions) available to the model.

[JsonInclude]
[JsonPropertyName("tools")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IReadOnlyList<Function> Tools { get; }

Property Value

IReadOnlyList<Function>

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.

[JsonInclude]
[JsonPropertyName("voice")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public string Voice { get; }

Property Value

string

VoiceActivityDetectionSettings

Configuration for turn detection. Can be set to null to turn off. 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.

[JsonInclude]
[JsonPropertyName("turn_detection")]
[JsonConverter(typeof(VoiceActivityDetectionSettingsConverter))]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IVoiceActivityDetectionSettings VoiceActivityDetectionSettings { get; }

Property Value

IVoiceActivityDetectionSettings