Skip to content

Realtime Tokens

Issue WebRTC session credentials backed by LiveKit-compatible access tokens. Use these to connect browser users directly to a voice agent without going through the full Calls API.

Create a Realtime Token

http
POST /v1/realtime/token

Creates a queued WebRTC call record and returns LiveKit-compatible credentials for the caller.

Request Body

FieldTypeRequiredDefaultDescription
agent_iduuidYesAgent the WebRTC caller should speak with
metadataobjectNo{}Custom data stored on the call record (tagged with type: "webrtc")

Example Request

bash
curl -X POST https://api.rymi.live/v1/realtime/token \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "metadata": {
      "source": "web-app",
      "user_id": "usr_456"
    }
  }'

Response 200

json
{
  "client_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "room_name": "webrtc_550e8400-e29b-41d4-a716-446655440000",
  "server_url": "wss://livekit.rymi.live"
}

Response Fields

FieldTypeDescription
client_tokenstringLiveKit-compatible JWT access token
room_namestringLiveKit room name for this session
server_urlstringWebSocket URL for the LiveKit server

Use these credentials with the Browser SDK or any LiveKit-compatible client:

typescript
import { Rymi } from '@rymi/web';

const call = Rymi.createCall({ url: serverUrl, token: clientToken });
call.on('started', () => console.log('Connected'));
await call.connect();

Errors

StatusMeaning
400Invalid payload (missing agent_id or malformed body)
401Missing authentication context
404Agent not found for the authenticated tenant
500LiveKit configuration or call-session initialization failed

Compatibility Alias

http
POST /v1/webrtc/token

This route behaves identically to POST /v1/realtime/token and exists for backward compatibility. New integrations should use /v1/realtime/token.