Realtime Audio
Realtime Audio
client.Realtime opens a bidirectional WebSocket session to wss://api.meshapi.ai/v1/realtime. The wire format is identical to OpenAI’s Realtime API — every event you send and receive is shaped exactly as upstream documents it.
Connect and close
Configure the session
Send audio
RealtimeMessage
Every frame from the server is a meshapi.RealtimeMessage. Exactly one of the fields below is non-zero per message:
Audio and text frames are mutually exclusive. Text frames always populate both Text and Event (unless the frame is not valid JSON, in which case only Text is set).
Receive frames
Receive blocks until the next frame arrives. Context cancellation unblocks it immediately:
Events channel (concurrent pump)
For concurrent send/receive, use Events to pump frames into a channel:
Full voice agent example
Error handling
Server errors arrive as a *meshapi.RealtimeError from Receive or on the errCh returned by Events: