# Realtime voice conversations (WebSocket)

Connect to `wss://api.xrtoken.ai/v1/realtime?model=xai/grok-voice-3.0` after the channel is enabled. Server clients use `Authorization: Bearer <key>`; browsers use the WebSocket protocols `["xrtoken.bearer", "<key>"]`. Never put a key in the URL.

Grok Voice 3.0 uses native xAI JSON events: send `session.update` with `voice`, `instructions`, and `turn_detection: {"type":"server_vad"}`, then send base64 PCM16 using `input_audio_buffer.append`. Default audio is 24 kHz mono. Receive `response.output_audio.delta` and `response.output_audio_transcript.delta`. Interruptions and client-side function tools are supported. Manual turns, session resumption and separately billed server-side tools are not supported in this release.

Automatic voice sessions are billed by duration including pauses, plus text `conversation.item.create` messages. Function results and audio items are exempt from the text fee. Funds are reserved before connecting and unused funds are released at settlement. `max_duration_seconds` is 1–600 (default 600); `max_text_messages` is 0–100 (default 20). The voice-only browser experience sets the text limit to 0. These gateway limits are not forwarded upstream. Missing credentials or pricing returns 503.

`doubao-realtime` continues to use the Volcengine binary protocol and token billing.

## GET /v1/realtime

> Realtime voice conversations (WebSocket)

Connect to `wss://api.xrtoken.ai/v1/realtime?model=xai/grok-voice-3.0` after the channel is enabled. Server clients use `Authorization: Bearer <key>`; browsers use the WebSocket protocols `["xrtoken.bearer", "<key>"]`. Never put a key in the URL.

Grok Voice 3.0 uses native xAI JSON events: send `session.update` with `voice`, `instructions`, and `turn_detection: {"type":"server_vad"}`, then send base64 PCM16 using `input_audio_buffer.append`. Default audio is 24 kHz mono. Receive `response.output_audio.delta` and `response.output_audio_transcript.delta`. Interruptions and client-side function tools are supported. Manual turns, session resumption and separately billed server-side tools are not supported in this release.

Automatic voice sessions are billed by duration including pauses, plus text `conversation.item.create` messages. Function results and audio items are exempt from the text fee. Funds are reserved before connecting and unused funds are released at settlement. `max_duration_seconds` is 1–600 (default 600); `max_text_messages` is 0–100 (default 20). The voice-only browser experience sets the text limit to 0. These gateway limits are not forwarded upstream. Missing credentials or pricing returns 503.

`doubao-realtime` continues to use the Volcengine binary protocol and token billing.

### Authentication

`Authorization: Bearer tr-xxx`

### Query Parameters

- **model** `string` **(required)**  
  
- **max_duration_seconds** `integer`  
  
- **max_text_messages** `integer`  
  

### Error Codes

- `101`: WebSocket connection established
- `401`: 
- `402`: 
- `503`: Channel credentials or pricing not configured
