Say something
Stream text from an LLM
Send text a token or a sentence at a time, thenfinish() the turn:
Interruptions (barge-in)
When the user starts talking, cancel the turn. Audio still on its way for that context is dropped, and iterating the context ends with a cancelled event.Events
Iterating a context yields, in order:
A turn that fails throws
RealtimeError (for example with code voice_not_found).
Limits and reconnects
- A session runs up to 4 contexts at once, and holds one of your plan’s concurrent-synthesis
slots until it closes. Opening one more than the plan allows throws
RateLimitErrorwith codeconcurrency_limited(waitretryAfterseconds), so reuse a session. - If the connection drops, running contexts throw
RealtimeError. Check itsretryableflag. The next context reconnects automatically; turn this off withconnect({ autoReconnect: false }). - Running out of credits ends the session with a
RealtimeErrorwhose code isinsufficient_credits. - Text is billed per character as it is sent. A session reserves credits in blocks of up to 1,000 characters and returns what it doesn’t use when it ends.

