RealtimeSessionCreateRequest class

Request for creating a realtime session via HTTP.

This endpoint creates an ephemeral API key that can be used to authenticate a WebSocket connection to the Realtime API.

Example

final response = await client.realtimeSessions.create(
  RealtimeSessionCreateRequest(
    model: 'gpt-realtime-1.5',
    voice: RealtimeVoice.alloy,
    instructions: 'You are a helpful assistant.',
  ),
);

// Use the client secret for WebSocket auth
print('Client secret: ${response.clientSecret.value}');
Annotations
  • @immutable

Constructors

RealtimeSessionCreateRequest({String? type, required String model, List<String>? modalities, String? instructions, RealtimeVoice? voice, RealtimeAudioFormat? inputAudioFormat, RealtimeAudioFormat? outputAudioFormat, InputAudioTranscription? inputAudioTranscription, TurnDetection? turnDetection, NoiseReductionConfig? inputAudioNoiseReduction, List<RealtimeTool>? tools, RealtimeToolChoice? toolChoice, double? temperature, InfOrInt? maxResponseOutputTokens})
Creates a RealtimeSessionCreateRequest.
const
RealtimeSessionCreateRequest.fromJson(Map<String, dynamic> json)
Creates a RealtimeSessionCreateRequest from JSON.
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
inputAudioFormat RealtimeAudioFormat?
Input audio format.
final
inputAudioNoiseReduction NoiseReductionConfig?
Input audio noise reduction configuration.
final
inputAudioTranscription InputAudioTranscription?
Configuration for input audio transcription.
final
instructions String?
System instructions for the model.
final
maxResponseOutputTokens InfOrInt?
Maximum output tokens ("inf" or a specific integer).
final
modalities List<String>?
The modalities enabled (e.g., "text", "audio").
final
model String
The model to use (required for HTTP, e.g., 'gpt-realtime-1.5').
final
outputAudioFormat RealtimeAudioFormat?
Output audio format.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
temperature double?
Sampling temperature (0.6-1.2).
final
toolChoice RealtimeToolChoice?
Tool choice setting.
final
tools List<RealtimeTool>?
Tools available to the model.
final
turnDetection TurnDetection?
Turn detection configuration.
final
type String?
The session type discriminator.
final
voice RealtimeVoice?
The voice to use for audio output.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts to JSON.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override