Principle:Openai Openai python Realtime Conversation Management
| Knowledge Sources | |
|---|---|
| Domains | Realtime_Communication, Conversation |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
An event-driven interaction pattern for sending conversation items and triggering model responses over a persistent Realtime API connection.
Description
Conversation management in the Realtime API involves two primary operations: adding items to the conversation (user messages, function call outputs) and triggering model responses. Unlike request-response APIs, these are separate events sent over the WebSocket. The model can also generate responses automatically based on voice activity detection (VAD).
Items can be inserted at specific positions using previous_item_id, and responses can override session-level settings for specific turns.
Usage
Use this principle to send user input and trigger model responses in a Realtime session. Call conversation.item.create() to add a message, then response.create() to trigger generation. In VAD mode, responses may be triggered automatically after detected speech.
Theoretical Basis
Conversation management follows an Event Sourcing pattern:
# 1. Add conversation item (user message)
connection.conversation.item.create(item={
"type": "message",
"role": "user",
"content": [{"type": "input_text", "text": "Hello"}]
})
# 2. Trigger model response
connection.response.create()
# 3. Server emits: response.created -> response.text.delta(s) -> response.done