Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai node Realtime Client Events

From Leeroopedia
Knowledge Sources
Domains Realtime, Conversation
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete typed event definitions for interacting with the OpenAI Realtime API provided by the openai-node SDK.

Description

The RealtimeClientEvent union type defines all events the client can send to the Realtime API. Key event types include:

  • conversation.item.create — Add a message or function call result to the conversation
  • response.create — Request a model response
  • input_audio_buffer.append — Send audio data
  • input_audio_buffer.commit — Finalize audio input
  • input_audio_buffer.clear — Discard buffered audio
  • conversation.item.delete — Remove a conversation item
  • response.cancel — Cancel an in-progress response

Usage

Send these events via rt.send() during an active Realtime session. Each event type has a specific typed payload.

Code Reference

Source Location

  • Repository: openai-node
  • File: src/resources/realtime/realtime.ts
  • Lines: L1451-1462 (RealtimeClientEvent union), L156 (ConversationItemCreateEvent), L3968-3983 (ResponseCreateEvent)

Signature

type RealtimeClientEvent =
  | ConversationItemCreateEvent
  | ConversationItemDeleteEvent
  | ConversationItemTruncateEvent
  | InputAudioBufferAppendEvent
  | InputAudioBufferClearEvent
  | InputAudioBufferCommitEvent
  | ResponseCancelEvent
  | ResponseCreateEvent
  | SessionUpdateEvent
  | TranscriptionSessionUpdate;

interface ConversationItemCreateEvent {
  type: 'conversation.item.create';
  item: {
    type: 'message' | 'function_call_output';
    role?: 'user' | 'assistant' | 'system';
    content?: Array<{ type: string; text?: string; audio?: string }>;
  };
}

interface ResponseCreateEvent {
  type: 'response.create';
  response?: { modalities?: Array<'text' | 'audio'>; instructions?: string };
}

interface InputAudioBufferAppendEvent {
  type: 'input_audio_buffer.append';
  audio: string;  // Base64-encoded audio data
}

Import

// No separate import needed — use rt.send() with typed event objects

I/O Contract

Inputs

Name Type Required Description
event RealtimeClientEvent Yes Typed event object with type discriminator and payload

Outputs

Name Type Description
(server events) Various Server responds with corresponding events: conversation.item.created, response.created, response.output_item.added, etc.

Usage Examples

Text Conversation

// Add a user message
rt.send({
  type: 'conversation.item.create',
  item: {
    type: 'message',
    role: 'user',
    content: [{ type: 'input_text', text: 'What is the weather today?' }],
  },
});

// Request a response
rt.send({ type: 'response.create' });

Audio Input

// Append audio data (base64-encoded PCM16)
rt.send({
  type: 'input_audio_buffer.append',
  audio: base64AudioChunk,
});

// Commit the audio buffer and request response
rt.send({ type: 'input_audio_buffer.commit' });
rt.send({ type: 'response.create' });

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment