Skip to main content

Connection Flow

After obtaining a session token, connect to the WebSocket endpoint and follow this sequence:

Authentication

The first message you send over the WebSocket must be a JSON string containing your session token. You have 10 seconds to send this message before the connection is closed.

Server Messages

The server sends two types of messages: text (JSON control messages) and binary (PCM audio frames from the AI agent).

Message Formats

Audio Format

Audio is streamed as raw PCM in both directions — the same format for microphone input and agent output. Send microphone audio as binary WebSocket messages. Each message should be exactly 640 bytes (one 20ms frame). Agent audio arrives in the same format.

Session Lifecycle

Next Steps

Now that you understand the protocol, head to the Web Guide or Flutter Guide for a complete implementation walkthrough.