RealtimeSession class
Configuration for a Realtime session.
The Realtime API enables real-time audio conversations with the model
using WebSockets. Audio configuration is nested under audio
(audio.input.* / audio.output.*), output modalities are configured
via outputModalities, and the maximum output token cap is set on
maxOutputTokens.
Note: the prompt field from the spec is intentionally not modelled in
this PR — the spec helper schema Prompt has no Dart class yet. Tracked
as a follow-up for prompt-template support.
- Annotations
-
- @immutable
Constructors
-
RealtimeSession({String? id, String? object, String? type, String? model, int? expiresAt, RealtimeAudioConfig? audio, List<
String> ? outputModalities, String? instructions, List<RealtimeTool> ? tools, RealtimeToolChoice? toolChoice, InfOrInt? maxOutputTokens, bool? parallelToolCalls, RealtimeReasoning? reasoning, RealtimeTracingConfig? tracing, RealtimeTruncation? truncation, List<String> ? include}) -
Creates a RealtimeSession.
const
-
RealtimeSession.fromJson(Map<
String, dynamic> json) -
Creates a RealtimeSession from JSON.
factory
Properties
- audio → RealtimeAudioConfig?
-
Nested audio configuration.
final
- expiresAt → int?
-
Expiration timestamp (Unix epoch seconds). May be
nullon partial frames before the session is fully provisioned.final - hashCode → int
-
The hash code for this object.
no setteroverride
- id → String?
-
The session identifier (
sess_…). Optional on partial frames.final -
include
→ List<
String> ? -
Additional fields to include in server outputs (e.g.
'item.input_audio_transcription.logprobs').final - instructions → String?
-
System instructions.
final
- maxOutputTokens → InfOrInt?
-
Maximum output tokens (
'inf'or a specific integer).final - model → String?
-
The model identifier. Always present for realtime sessions; omitted
for transcription sessions (which don't carry a top-level model).
final
- object → String?
-
The object type (e.g.
'realtime.session'). Optional on partial frames.final -
outputModalities
→ List<
String> ? -
Output modalities (e.g.
['audio']or['text']). Defaults to['audio']. The server only accepts a single modality at a time.final - parallelToolCalls → bool?
-
Whether the model may call multiple tools in parallel. Only supported by
reasoning Realtime models such as
gpt-realtime-2.final - reasoning → RealtimeReasoning?
-
Reasoning configuration. Only supported by reasoning models.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- toolChoice → RealtimeToolChoice?
-
Tool choice setting.
final
-
tools
→ List<
RealtimeTool> ? -
Tools available to the model.
final
- tracing → RealtimeTracingConfig?
-
Tracing configuration.
final
- truncation → RealtimeTruncation?
-
Truncation configuration.
final
- type → String?
-
The session type (
'realtime'or'transcription'). Optional on partial frames.final
Methods
-
copyWith(
{Object? id = unsetCopyWithValue, Object? object = unsetCopyWithValue, Object? type = unsetCopyWithValue, Object? model = unsetCopyWithValue, Object? expiresAt = unsetCopyWithValue, Object? audio = unsetCopyWithValue, Object? outputModalities = unsetCopyWithValue, Object? instructions = unsetCopyWithValue, Object? tools = unsetCopyWithValue, Object? toolChoice = unsetCopyWithValue, Object? maxOutputTokens = unsetCopyWithValue, Object? parallelToolCalls = unsetCopyWithValue, Object? reasoning = unsetCopyWithValue, Object? tracing = unsetCopyWithValue, Object? truncation = unsetCopyWithValue, Object? include = unsetCopyWithValue}) → RealtimeSession - Returns a copy of this RealtimeSession with the given fields replaced.
-
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