AsyncAPI 2.6 description of Layercode's **realtime voice transport**, a genuine bidirectional WebSocket documented at https://docs.layercode.com/api-reference/frontend-ws-api. Unlike one-way HTTP SSE, this is a true full-duplex WebSocket. The browser opens the connection at `wss://api.layercode.com/v1/agents/web/websocket?client_session_key=...` using a short-lived `client_session_key` obtained from the REST endpoint `POST /v1/agents/web/authorize_session` (modeled in `openapi/layercode-openapi.yml`). Over the socket the client streams base64-encoded 16-bit PCM microphone audio (8000 Hz, mono) to Layercode, and Layercode streams back synthesized speech (base64 16-bit PCM, 16000 Hz, mono), interim and final transcripts, streamed assistant text, and structured data, organized into user and assistant turns identified by `turn_id`. The companion webhook surface - where Layercode POSTs transcript events to your backend and your backend streams response.tts / response.data / response.end events back as Server-Sent Events - is documented at https://docs.layercode.com/api-reference/webhook-sse-api and summarized in `info.x-webhook-notes` below; it is a separate HTTP+SSE channel and is not modeled as WebSocket here.
Realtime voice channel. Opened by the browser with `?client_session_key=...`. Both directions exchange JSON text frames; all audio payloads are carried as base64 strings inside JSON messages.
Messages
✉
ClientReady
Client ready
Signals the client is connected and ready to stream.
✉
ClientAudio
Client audio chunk
A chunk of microphone audio from the browser.
✉
TriggerTurnStart
Turn start trigger (push-to-talk)
✉
TriggerTurnEnd
Turn end trigger (push-to-talk)
✉
TriggerAudioReplayFinished
Audio replay finished
Client finished playing back a response audio turn.
✉
ClientResponseText
Client text message
A typed text message from the user.
✉
ClientResponseData
Client structured data
Arbitrary structured JSON emitted by the client UI.
✉
TurnStart
Turn start
✉
ResponseAudio
Response audio chunk
Synthesized speech audio from Layercode.
✉
ResponseTextDelta
Response text delta
✉
ResponseText
Response text (complete)
✉
UserTranscriptInterimDelta
Interim transcript delta
✉
UserTranscriptDelta
Final transcript delta
✉
UserTranscript
Complete turn transcript
✉
ResponseData
Response structured data
Structured JSON pushed to the client without audio.
Layercode realtime voice WebSocket. The browser connects with a short-lived client_session_key query parameter. The connection is full-duplex: the client publishes microphone audio and control messages, and the server publishes audio, transcripts, text, and data events.