openai_realtime_dart library

Dart client for the OpenAI Realtime API (beta), a stateful, event-based API that communicates over a WebSocket.

Classes

APIError
Details of the API error.
ContentPart
A part of the content.
ContentPartItemReference
A part of the item reference content.
Conversation
The conversation resource.
Delta
Delta object.
EventHandlerResult
No Description
FormattedItem
A formatted item.
FormattedProperty
A formatted property.
FormattedTool
A formatted tool.
InputAudioTranscriptionConfig
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.
Item
The item to add to the conversation.
ItemSpeech
The speech item.
ItemTranscript
The transcript item.
RateLimit
Rate limit information.
RealtimeAPI
Thin wrapper over WebSocket to handle the communication with OpenAI Realtime API.
RealtimeClient
Dart client for the OpenAI Realtime API. Enables rapid application development with a simplified control flow.
RealtimeConversation
Stores a client-side cache of the current conversation and performs event validation to make sure it can cache them properly.
RealtimeEvent
A Realtime API event.
RealtimeEventHandler
Inherited class for RealtimeAPI and RealtimeClient. Adds basic event handling.
Response
The response resource.
ResponseConfig
Configuration for the response.
ResponseConfigConversation
Controls which conversation the response is added to. Currently supports auto and none, with auto as the default value. The auto value means that the contents of the response will be added to the default conversation. Set this to none to create an out-of-band response which will not add items to default conversation.
ResponseConfigMaxResponseOutputTokens
Maximum number of output tokens for a single assistant response, inclusive of tool calls. Defaults to "inf".
ResponseConfigToolChoice
How the model chooses tools.
ResponseStatusDetails
The type of error that caused the response to fail, corresponding with the status field (completed, cancelled, incomplete, failed).
Session
The session resource.
SessionConfig
Session configuration to update.
SessionConfigClientSecret
Ephemeral key returned by the API.
SessionConfigMaxResponseOutputTokens
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.
SessionConfigToolChoice
How the model chooses tools. Options are auto, none, required, or specify a function.
SessionMaxResponseOutputTokens
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.
SessionToolChoice
How the model chooses tools.
ToolChoiceForced
Specifies a tool the model should use. Use to force the model to call a specific function.
ToolDefinition
The definition of a tool the model may use.
TranscriptionError
Details of the transcription error.
TurnDetection
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.
Uint8ListConverter
Usage
Usage statistics for the Response, this will correspond to billing. A Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns.
UsageInputTokenDetails
Details about the input tokens used in the Response.
UsageOutputTokenDetails
Details about the output tokens used in the Response.

Enums

AudioFormat
The format of the audio.
ContentPartEnumType
ContentType
The type of the content.
ItemEnumType
ItemRole
The role associated with the item.
ItemStatus
The status of the item.
ItemType
The type of the item.
Modality
The modality of the model response.
ObjectType
The object type.
RateLimitName
The name of the rate limit.
RealtimeEventEnumType
RealtimeEventType
The type of the event.
ResponseConfigConversationEnum
No Description
ResponseConfigToolChoiceMode
none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
ResponseStatus
The status of the response.
ResponseStatusDetailsEnumType
ResponseStatusReason
The reason the Response did not complete. For a cancelled Response, one of turn_detected (the server VAD detected a new start of speech) or client_cancelled (the client sent a cancel event). For an incomplete Response, one of max_output_tokens or content_filter (the server-side safety filter activated and cut off the response).
ResponseStatusType
The type of error that caused the response to fail.
SessionConfigToolChoiceMode
none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
SessionToolChoiceMode
none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
ToolType
The type of the tool. Currently, only function is supported.
TurnDetectionType
The type of turn detection.
Voice
The voice used by the model.

Extensions

APIErrorPatterns on APIError
Adds pattern-matching-related methods to APIError.
ContentPartItemReferencePatterns on ContentPartItemReference
Adds pattern-matching-related methods to ContentPartItemReference.
ContentPartPatterns on ContentPart
Adds pattern-matching-related methods to ContentPart.
ConversationPatterns on Conversation
Adds pattern-matching-related methods to Conversation.
DeltaPatterns on Delta
Adds pattern-matching-related methods to Delta.
EventHandlerResultPatterns on EventHandlerResult
Adds pattern-matching-related methods to EventHandlerResult.
FormattedItemPatterns on FormattedItem
Adds pattern-matching-related methods to FormattedItem.
FormattedPropertyPatterns on FormattedProperty
Adds pattern-matching-related methods to FormattedProperty.
FormattedToolPatterns on FormattedTool
Adds pattern-matching-related methods to FormattedTool.
InputAudioTranscriptionConfigPatterns on InputAudioTranscriptionConfig
Adds pattern-matching-related methods to InputAudioTranscriptionConfig.
ItemPatterns on Item
Adds pattern-matching-related methods to Item.
ItemSpeechPatterns on ItemSpeech
Adds pattern-matching-related methods to ItemSpeech.
ItemTranscriptPatterns on ItemTranscript
Adds pattern-matching-related methods to ItemTranscript.
RateLimitPatterns on RateLimit
Adds pattern-matching-related methods to RateLimit.
RealtimeEventPatterns on RealtimeEvent
Adds pattern-matching-related methods to RealtimeEvent.
ResponseConfigConversationPatterns on ResponseConfigConversation
Adds pattern-matching-related methods to ResponseConfigConversation.
ResponseConfigMaxResponseOutputTokensPatterns on ResponseConfigMaxResponseOutputTokens
Adds pattern-matching-related methods to ResponseConfigMaxResponseOutputTokens.
ResponseConfigPatterns on ResponseConfig
Adds pattern-matching-related methods to ResponseConfig.
ResponseConfigToolChoicePatterns on ResponseConfigToolChoice
Adds pattern-matching-related methods to ResponseConfigToolChoice.
ResponsePatterns on Response
Adds pattern-matching-related methods to Response.
ResponseStatusDetailsPatterns on ResponseStatusDetails
Adds pattern-matching-related methods to ResponseStatusDetails.
SessionConfigClientSecretPatterns on SessionConfigClientSecret
Adds pattern-matching-related methods to SessionConfigClientSecret.
SessionConfigMaxResponseOutputTokensPatterns on SessionConfigMaxResponseOutputTokens
Adds pattern-matching-related methods to SessionConfigMaxResponseOutputTokens.
SessionConfigPatterns on SessionConfig
Adds pattern-matching-related methods to SessionConfig.
SessionConfigToolChoicePatterns on SessionConfigToolChoice
Adds pattern-matching-related methods to SessionConfigToolChoice.
SessionMaxResponseOutputTokensPatterns on SessionMaxResponseOutputTokens
Adds pattern-matching-related methods to SessionMaxResponseOutputTokens.
SessionPatterns on Session
Adds pattern-matching-related methods to Session.
SessionToolChoicePatterns on SessionToolChoice
Adds pattern-matching-related methods to SessionToolChoice.
ToolChoiceForcedPatterns on ToolChoiceForced
Adds pattern-matching-related methods to ToolChoiceForced.
ToolDefinitionPatterns on ToolDefinition
Adds pattern-matching-related methods to ToolDefinition.
TranscriptionErrorPatterns on TranscriptionError
Adds pattern-matching-related methods to TranscriptionError.
TurnDetectionPatterns on TurnDetection
Adds pattern-matching-related methods to TurnDetection.
UsageInputTokenDetailsPatterns on UsageInputTokenDetails
Adds pattern-matching-related methods to UsageInputTokenDetails.
UsageOutputTokenDetailsPatterns on UsageOutputTokenDetails
Adds pattern-matching-related methods to UsageOutputTokenDetails.
UsagePatterns on Usage
Adds pattern-matching-related methods to Usage.

Typedefs

EventHandlerCallback = FutureOr<void> Function(RealtimeEvent event)
EventHandler callback.
ToolHandler = FutureOr<Map<String, dynamic>> Function(Map<String, dynamic>)
The handler for a tool.