Skip to main content
Use the Vatel Go SDK to call the REST and WebSocket APIs from Go. One client handles both: REST for your organization and WebSocket for real-time voice sessions: receive events, send input audio, and handle tool calls.

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

1

Install the SDK

2

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:
3

Open the WebSocket connection

Dial the connection with the token and consume messages:
4

Send audio

Send microphone (or other) audio as PCM 16-bit 24 kHz mono. Use base64 or raw bytes:

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:
  1. Connect - client.DialConnection(ctx, tokenResp.Token) opens the WebSocket. For a custom dialer, use client.ConnectionURL(token) and vatel.DialConnection(ctx, url, nil).
  2. Send - conn.SendInputAudio(base64PCM) or conn.SendInputAudioBytes(pcm) for input audio; conn.SendToolCallOutput(toolCallID, output) for tool results.
  3. Receive - conn.Receive() for one message, or conn.Messages() for a channel. Use msg.ParseData() to get typed structs (SessionStartedData, ResponseAudioData, ToolCallData, etc.).
When done, call conn.Close() or conn.CloseWithReason(code, text).

Error handling

  • REST errors are returned as *vatel.APIError with StatusCode and Body. Use them to handle 4xx/5xx responses.
  • Sending on a closed WebSocket returns vatel.ErrConnectionClosed.