AI Dev Kit
Search Results for

    Show / Hide Table of Contents

    Class RealtimeEventReceiverBase

    Extend this class if you want to do custom handling of Realtime Events.

    Inheritance
    object
    RealtimeEventReceiverBase
    RealtimeEventReceiver
    Namespace: Glitch9.AIDevKit.OpenAI.Realtime
    Assembly: .dll
    Syntax
    public abstract class RealtimeEventReceiverBase

    Fields

    OnSessionStateChanged

    Declaration
    protected Action<string> OnSessionStateChanged
    Field Value
    Type Description
    Action<string>

    Methods

    OnConversationCreated(string, Conversation)

    Returned when a conversation is created. Emitted right after session creation.

    Declaration
    public virtual void OnConversationCreated(string eventId, Conversation conversation)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    Conversation conversation

    The conversation resource.

    OnConversationItemCreated(string, string, RealtimeItem)

    Returned when a conversation item is created.

    Declaration
    public virtual void OnConversationItemCreated(string eventId, string previousItemId, RealtimeItem item)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string previousItemId

    The ID of the preceding item.

    RealtimeItem item

    The newly created conversation item.

    OnConversationItemDeleted(string, string)

    Returned when an item in the conversation is deleted.

    Declaration
    public virtual void OnConversationItemDeleted(string eventId, string itemId)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string itemId

    The ID of the item that was deleted.

    OnConversationItemInputAudioTranscriptionCompleted(string, int?, string)

    Returned when input audio transcription is enabled and a transcription succeeds.

    Declaration
    public virtual void OnConversationItemInputAudioTranscriptionCompleted(string eventId, int? contentIndex, string transcription)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    int? contentIndex

    The index of the content part containing the audio.

    string transcription

    The transcribed text.

    OnConversationItemInputAudioTranscriptionDelta(string, string, int?, string)

    Declaration
    public virtual void OnConversationItemInputAudioTranscriptionDelta(string eventId, string itemId, int? contentIndex, string delta)
    Parameters
    Type Name Description
    string eventId
    string itemId
    int? contentIndex
    string delta

    OnConversationItemInputAudioTranscriptionFailed(string, int?, ErrorResponse)

    Returned when input audio transcription is configured, and a transcription request for a user message failed.

    Declaration
    public virtual void OnConversationItemInputAudioTranscriptionFailed(string eventId, int? contentIndex, ErrorResponse error)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    int? contentIndex

    The index of the content part containing the audio.

    ErrorResponse error

    Details of the transcription error.

    OnConversationItemTruncated(string, string, int?, int?)

    Returned when an earlier assistant audio message item is truncated by the client.

    Declaration
    public virtual void OnConversationItemTruncated(string eventId, string itemId, int? contentIndex, int? audioEndMs)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string itemId

    The ID of the assistant message item that was truncated.

    int? contentIndex

    The index of the content part that was truncated.

    int? audioEndMs

    The duration up to which the audio was truncated, in milliseconds.

    OnError(string, ErrorResponse)

    Returned when an error occurs.

    Declaration
    public virtual void OnError(string eventId, ErrorResponse error)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    ErrorResponse error

    Details of the error.

    OnInputAudioBufferCleared(string)

    Returned when the input audio buffer is cleared by the client.

    Declaration
    public virtual void OnInputAudioBufferCleared(string eventId)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    OnInputAudioBufferCommitted(string, string, string)

    Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode.

    Declaration
    public virtual void OnInputAudioBufferCommitted(string eventId, string previousItemId, string itemId)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string previousItemId

    The ID of the preceding item.

    string itemId

    The ID of the new item.

    OnInputAudioBufferSpeechStarted(string, int?, string)

    Returned in server turn detection mode when speech is detected.

    Declaration
    public virtual void OnInputAudioBufferSpeechStarted(string eventId, int? audioStartMs, string itemId)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    int? audioStartMs

    Milliseconds since the session started when speech was detected.

    string itemId

    The ID of the new item.

    OnInputAudioBufferSpeechStopped(string, int?, string)

    Returned in server turn detection mode when speech stops.

    Declaration
    public virtual void OnInputAudioBufferSpeechStopped(string eventId, int? audioEndMs, string itemId)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    int? audioEndMs

    Milliseconds since the session started when speech stopped.

    string itemId

    The ID of the new item.

    OnRateLimitsUpdated(string, RateLimit[])

    Emitted after every "response.done" event to indicate the updated rate limits.

    Declaration
    public virtual void OnRateLimitsUpdated(string eventId, RateLimit[] rateLimits)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    RateLimit[] rateLimits

    List of rate limit information.

    OnRealtimeEventReceived(RealtimeEvent)

    Declaration
    public void OnRealtimeEventReceived(RealtimeEvent realtimeEvent)
    Parameters
    Type Name Description
    RealtimeEvent realtimeEvent

    OnResponseAudioDelta(string, string, string, int?, int?, string)

    Returned when the model-generated audio is updated.

    Declaration
    public virtual void OnResponseAudioDelta(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, string delta)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    string delta

    Base64-encoded audio data delta.

    OnResponseAudioDone(string, string, string, int?, int?)

    Returned when the model-generated audio is done.

    Declaration
    public virtual void OnResponseAudioDone(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    OnResponseAudioTranscriptDelta(string, string, string, int?, int?, string)

    Returned when the model-generated transcription of audio output is updated.

    Declaration
    public virtual void OnResponseAudioTranscriptDelta(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, string delta)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    string delta

    The transcript delta.

    OnResponseAudioTranscriptDone(string, string, string, int?, int?, string)

    Returned when the model-generated transcription of audio output is done streaming.

    Declaration
    public virtual void OnResponseAudioTranscriptDone(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, string transcript)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    string transcript

    The final transcript of the audio.

    OnResponseContentPartAdded(string, string, string, int?, int?, RealtimeItemContent)

    Returned when a new content part is added to an assistant message item during response generation.

    Declaration
    public virtual void OnResponseContentPartAdded(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, RealtimeItemContent part)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item to which the content part was added.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    RealtimeItemContent part

    The added content part.

    OnResponseContentPartDone(string, string, string, int?, int?, RealtimeItemContent)

    Returned when a content part is done streaming in an assistant message item.

    Declaration
    public virtual void OnResponseContentPartDone(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, RealtimeItemContent part)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    RealtimeItemContent part

    The completed content part.

    OnResponseCreated(string, RealtimeItem)

    Returned when a new Response is created.

    Declaration
    public virtual void OnResponseCreated(string eventId, RealtimeItem response)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    RealtimeItem response

    The response resource.

    OnResponseDone(string, RealtimeItem)

    Returned when a Response is done streaming. Always emitted, no matter the final state.

    Declaration
    public virtual void OnResponseDone(string eventId, RealtimeItem response)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    RealtimeItem response

    The response resource.

    OnResponseFunctionCallArgumentsDelta(string, string, string, int?, string, string)

    Returned when the model-generated function call arguments are updated.

    Declaration
    public virtual void OnResponseFunctionCallArgumentsDelta(string eventId, string responseId, string itemId, int? itemIndex, string callId, string delta)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the function call item.

    int? itemIndex
    string callId

    The ID of the function call.

    string delta

    The arguments delta as a JSON string.

    OnResponseFunctionCallArgumentsDone(string, string, string, int?, string, string)

    Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

    Declaration
    public virtual void OnResponseFunctionCallArgumentsDone(string eventId, string responseId, string itemId, int? itemIndex, string callId, string arguments)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the function call item.

    int? itemIndex
    string callId

    The ID of the function call.

    string arguments

    The final arguments as a JSON string.

    OnResponseOutputItemAdded(string, string, int?, RealtimeItem)

    Returned when a new Item is created during response generation.

    Declaration
    public virtual void OnResponseOutputItemAdded(string eventId, string responseId, int? itemIndex, RealtimeItem item)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response to which the item belongs.

    int? itemIndex
    RealtimeItem item

    The created item.

    OnResponseOutputItemDone(string, string, int?, RealtimeItem)

    Returned when an Item is done streaming.

    Declaration
    public virtual void OnResponseOutputItemDone(string eventId, string responseId, int? itemIndex, RealtimeItem item)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response to which the item belongs.

    int? itemIndex
    RealtimeItem item

    The completed item.

    OnResponseTextDelta(string, string, string, int?, int?, string)

    Returned when the text value of a "text" content part is updated.

    Declaration
    public virtual void OnResponseTextDelta(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, string delta)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    string delta

    The text delta.

    OnResponseTextDone(string, string, string, int?, int?, string)

    Returned when the text value of a "text" content part is done streaming.

    Declaration
    public virtual void OnResponseTextDone(string eventId, string responseId, string itemId, int? itemIndex, int? contentIndex, string text)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    string responseId

    The ID of the response.

    string itemId

    The ID of the item.

    int? itemIndex
    int? contentIndex

    The index of the content part in the item's content array.

    string text

    The final text content.

    OnSessionCreated(string, RealtimeSession)

    Returned when a session is created. Emitted automatically when a new connection is established.

    Declaration
    public virtual void OnSessionCreated(string eventId, RealtimeSession session)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    RealtimeSession session

    The session resource.

    OnSessionUpdated(string, RealtimeSession)

    Returned when a session is updated.

    Declaration
    public virtual void OnSessionUpdated(string eventId, RealtimeSession session)
    Parameters
    Type Name Description
    string eventId

    The unique ID of the event.

    RealtimeSession session

    The updated session resource.

    In this article
    Back to top Generated by DocFX