Session token
REST endpoint used to obtain a short-lived JWT for the WebSocket connection.
Connection
WebSocket channel, message types, and request/response flow.
Prerequisites
- Go 1.21+
- Organization API key from the Vatel dashboard
- Agent ID (agent UUID) for the agent you want to run the call with
Walkthrough
Create a client and get a session token
Create a client with the API base URL and your API key, then obtain a session token for the agent:
REST API
The same client exposes the REST API. See the API reference for all endpoints. You can pass a custom HTTP client:WebSocket (call session)
After you have a session token:- Connect —
client.DialConnection(ctx, tokenResp.Token)opens the WebSocket. For a custom dialer, useclient.ConnectionURL(token)andvatel.DialConnection(ctx, url, nil). - Send —
conn.SendInputAudio(base64PCM)orconn.SendInputAudioBytes(pcm)for input audio;conn.SendToolCallOutput(toolCallID, output)for tool results. - Receive —
conn.Receive()for one message, orconn.Messages()for a channel. Usemsg.ParseData()to get typed structs (SessionStartedData,ResponseAudioData,ToolCallData, etc.).
conn.Close() or conn.CloseWithReason(code, text).
Error handling
- REST errors are returned as
*vatel.APIErrorwithStatusCodeandBody. Use them to handle 4xx/5xx responses. - Sending on a closed WebSocket returns
vatel.ErrConnectionClosed.

