RealtimeClientProtocol

@runtime_checkable
class RealtimeClientProtocol(Protocol)

send_function_result

async def send_function_result(call_id: str, result: str) -> None

Send the result of a function call to a Realtime API.

Arguments:

  • call_id str - The ID of the function call.
  • result str - The result of the function call.

send_text

async def send_text(*, role: Role, text: str) -> None

Send a text message to a Realtime API.

Arguments:

  • role str - The role of the message.
  • text str - The text of the message.

send_audio

async def send_audio(audio: str) -> None

Send audio to a Realtime API.

Arguments:

  • audio str - The audio to send.

truncate_audio

async def truncate_audio(audio_end_ms: int, content_index: int,
                         item_id: str) -> None

Truncate audio in a Realtime API.

Arguments:

  • audio_end_ms int - The end of the audio to truncate.
  • content_index int - The index of the content to truncate.
  • item_id str - The ID of the item to truncate.

session_update

async def session_update(session_options: dict[str, Any]) -> None

Send a session update to a Realtime API.

Arguments:

  • session_options dict[str, Any] - The session options to update.

read_events

def read_events() -> AsyncGenerator[dict[str, Any], None]

Read messages from a Realtime API.