Endpoint
GET with Connection: Upgrade and Upgrade: websocket). Anything else is refused with 426.
Authentication
Send your Comfy API key in a header on the upgrade request, either asX-API-Key: comfyui-... or as Authorization: Bearer comfyui-.... Router does not read a key from the query string or from the WebSocket subprotocol.
Connect
Once the upgrade succeeds, send and receive the realtime events xAI documents for Grok Voice. This example configures the session, sends one text turn, and prints each event type it receives.Events
Router does not define its own event protocol. Server events reach you exactly as fal sends them, and the client events Router accepts are forwarded unchanged. For the event list, session fields, voices, and audio formats, see:- xAI Speech to Speech and xAI’s realtime event schema
- fal’s Grok Voice realtime model page and its API page
session.created. fal also sends its own JSON text messages of type x-fal-message (timing information); you can skip them. Router’s checks also accept a client event as one JSON text message, but use msgpack unless you have tested JSON with your client.
Router checks each client event before forwarding it:
- Event types:
session.update,input_audio_buffer.append,input_audio_buffer.commit,input_audio_buffer.clear,conversation.item.create,conversation.item.delete,conversation.item.truncate,response.create,response.cancel, and fal’sx-fal-session.configure. - Models: a
modelinsession.updatemust begrok-voice-latest,grok-voice-3.0, orgrok-voice-2.0. - Tools: function tools that your client executes are allowed. Server-side tools (web search, X search, file search, and MCP) are refused.
- Media: image and video input is refused. The session is voice and text only.
- Size: one client message may be at most 1 MiB.
1008.
Pricing
A session costs **$0.00083 per second** (about $0.05 per minute, or about 0.175 credits per second at 211 credits = $1 USD). It is billed in 15-second increments while the session is open, and the final partial increment is billed by the second, rounded up. Billing runs from the upgrade until the socket closes, whether or not audio is flowing.Limits
When a session reaches its time limit or runs out of credits, the connection may close without a close frame (often surfaced as close code
1006). Reconnect only after topping up, or start a new session if you need more time.
Errors
Before the upgrade
If Router refuses the connection, it answers with an HTTP status and a JSON body instead of switching protocols:code; detail is for people.
After the upgrade
Any other close comes from fal or xAI. See their documentation linked under Events.
Next
- Billing: how Router charges and how to reconcile usage.
- Errors and retries: the error buckets other Router calls return.
- Limitations: request rates and other limits.