Skip to main content
Triggered when the real-time session is created. This event is received after conversation.connected.success and after you send the realtime.input_config message. After receiving this event, you should send conversation history (if any) using conversation.item.create messages.

Event Properties

type
string
Event type. Always "realtime.session.created" for this event.
data
object
Event data object. May be empty or contain session metadata.
{
  "type": "realtime.session.created",
  "data": {}
}

Sending Conversation History

After receiving realtime.session.created, send conversation history (if any) using conversation.item.create messages. Only send user messages from history:
async function sendSessionUpdate() {
    const history = localStorage.getItem('realtimeChatHistory');
    const conversationHistory = history ? JSON.parse(history) : [];
    
    // Only send user messages
    conversationHistory.forEach((msg) => {
        if (msg.role === 'user') {
            const messageConfig = {
                type: 'conversation.item.create',
                item: {
                    type: 'message',
                    role: msg.role,
                    content: [{ type: 'input_text', text: msg.content }]
                }
            };
            socket.send(JSON.stringify(messageConfig));
        }
    });
}
Session configuration (voice, prompt, tools) is sent via realtime.input_config message immediately after the WebSocket connection opens. The sendSessionUpdate() function is only used to send conversation history after receiving realtime.session.created.The tools parameter is optional and only applicable when using OpenAI models (gpt-realtime, gpt-realtime-mini). Function calling is not supported by other AI models.