Appearance
Realtime
See the Realtime voice guide for the flow, the full protocol and limits.
Create a session
http
POST /v1/realtime/sessionsScope: realtime:session. Call it from your backend; give only the token to the end user's app.
| Body field | Type | Description |
|---|---|---|
agent | string (1–64) | required; slug of a published realtime agent |
externalUserId | string (1–200) | your end user's id |
metadata | object | stored with the session |
Response 201:
| Field | Description |
|---|---|
token | single-use session token |
url | the WebSocket URL (wss://…/v1/realtime) |
expiresAt | connect before this time (about two minutes) |
sessionId | the session's id |
bash
curl "$HEVKAR_BASE_URL/v1/realtime/sessions" \
-H "Authorization: Bearer $HEVKAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"agent": "voice-concierge", "externalUserId": "user_42"}'ts
const { token, url, expiresAt, sessionId } = await hevkar.realtime.createSession({
agent: 'voice-concierge',
externalUserId: 'user_42',
metadata: { plan: 'pro' },
});| Status | Code | When |
|---|---|---|
| 403 | MISSING_SCOPE | the key lacks realtime:session |
| 404 | NOT_FOUND | no agent with this slug |
| 403 | AGENT_NOT_ALLOWED | the key is restricted to other agents |
| 400 | AGENT_NOT_REALTIME | not a realtime agent (checked before publication) |
| 409 | AGENT_NOT_PUBLISHED | the agent has no published version |
| 403 | ORG_SUSPENDED | the organization is suspended |
| 402 | QUOTA_EXCEEDED | monthly spend cap reached |
| 400 | REALTIME_NOT_CONFIGURED | the agent has no realtime settings |
| 400 | MODEL_UNAVAILABLE | the realtime model is unknown, disabled or not usable |
| 429 | REALTIME_SESSION_LIMIT | concurrent session limit reached |
The checks run in the order of this table; the first failing one answers.
WebSocket
text
GET wss://api.example.com/v1/realtime?token=<token>or with Sec-WebSocket-Protocol: hevkar-realtime, token.<token> (the server answers with hevkar-realtime). Frames are JSON text with a type; audio is base64 PCM16 little-endian mono 24 kHz, and clients may send raw PCM16 binary frames. Maximum client frame: 1 MiB.
| Direction | Events |
|---|---|
| client → server | input_audio.append, input_audio.commit, input_audio.clear, conversation.item.create, response.create, response.cancel, session.update |
| server → client | session.ready, audio.delta, audio.done, transcript.delta, transcript.done, speech.started, speech.stopped, tool.call, tool.result, response.done, error, session.ended |
Fields, end reasons and close codes: Protocol. Error codes: Realtime WebSocket errors.