Skip to main content

Overview

The Realtime API uses an event-based protocol where both client and server send events over the WebSocket connection. Events are JSON objects with a type field that determines their structure and purpose.

Event Categories

Server Events

Events sent from the server to the client:
  • Session events: session.created, session.updated
  • Conversation events: conversation.created, conversation.item.created, conversation.item.deleted
  • Input audio events: input_audio_buffer.committed, input_audio_buffer.cleared, input_audio_buffer.speech_started, input_audio_buffer.speech_stopped
  • Response events: response.created, response.done, response.output_item.added, response.content_part.added
  • Audio events: response.audio.delta, response.audio.done, response.audio_transcript.delta
  • Error events: error

Client Events

Events sent from the client to the server:
  • Session control: session.update
  • Input audio: input_audio_buffer.append, input_audio_buffer.commit, input_audio_buffer.clear
  • Conversation management: conversation.item.create, conversation.item.delete, conversation.item.truncate
  • Response control: response.create, response.cancel

Sending Events

Response Creation

Trigger model inference to generate a response:

Cancel Response

Cancel an in-progress response:

Input Audio Buffer

Append Audio

Commit Audio Buffer

Create a user message from the audio buffer:

Clear Audio Buffer

Conversation Management

Create Conversation Item

Add a message to the conversation:

Delete Conversation Item

Truncate Audio

Truncate assistant audio that hasn’t been played:

Receiving Events

Event Loop Pattern

Event Properties

All events include:
string
The event type identifier
string
Unique identifier for the event

Common Event Types

Session Created

Received when connection is established:

Response Audio Delta

Streaming audio output from the model:

Response Done

Indicates response completion:

Error Event

Advanced Patterns

Function Calling

Handle function calls from the model:

Interruption Handling

Text-Only Mode

Async Event Handling

Notes

  • Events are processed in order
  • Some events (like input_audio_buffer.append) don’t receive confirmation responses
  • Use event_id parameter to track specific events
  • The server may send multiple events in rapid succession
  • Connection automatically handles WebSocket framing and parsing