EVA Gateway WebSocket API
EVA Gateway provides a bidirectional streaming ASR API over WebSocket. Send audio continuously while receiving real-time transcription results. The API implements a subset of the transcription events in the OpenAI Realtime API. Model, audio format, and sample rate settings are consistent with the HTTP ASR API. See ASR Parameters for accepted values and model restrictions.
ASR only; TTS is not currently supported. Only some ASR models support real-time transcription over WebSocket. Check the Model Hub for model details, supported interfaces, and audio requirements.
Connection and Authentication
Connection URL:
wss://eva-gateway.autoarkai.com/v1/realtime
Include your API Key in the handshake request headers when establishing the WebSocket connection:
Authorization: Bearer <YOUR_API_KEY>
Session Flow
- Establish a WebSocket connection and wait for
session.createdfrom the server. - Send
session.updateto configure the model, audio format, and turn detection mode. - After receiving
session.updated, send Base64-encoded audio chunks continuously usinginput_audio_buffer.append. - The server returns real-time transcription results and completes each turn according to the selected mode: automatically in
server_vadmode, or when the client sendsinput_audio_buffer.commitin manual mode. - Close the connection after sending all audio and receiving the final result. If there is no speech input for an extended period, the server closes the connection after the silence timeout.
Turn Detection Modes
Set the turn detection mode using session.audio.input.turn_detection:
server_vad(omitturn_detectionor set it to{"type": "server_vad"}): the server detects turn boundaries based on silence. No client action is required.- Manual (explicitly set
turn_detection: null): the client determines turn boundaries by sendinginput_audio_buffer.commit. Useinput_audio_buffer.clearto discard audio that has not yet been committed.
See the turn_detection column in the Model List for the modes supported by each model. An unsupported mode is rejected during session.update.
Silence Timeout
If no text is recognized within 60 seconds, the server sends an error with code: "51005" and closes the connection.
Note: Some upstream providers close the connection if they receive no audio frames for a certain period. Handle this on the client, for example by sending silence frames, monitoring connection close events, and reconnecting when needed.
Sequence Diagram
Each message is a JSON text frame. The Gateway generates event_id values to identify events; clients should not depend on their specific format.
Client Events
session.update
After receiving session.created, send this event to initialize the transcription session. Set the model using session.audio.input.transcription.model.
{
"type": "session.update",
"session": {
"type": "transcription",
"audio": {
"input": {
"format": {
"audio_format": "pcm",
"sample_rate": 16000,
"channels": 1
},
"transcription": {
"model": "<REALTIME_ASR_MODEL_ID>",
"keywords": "EVA,AutoArk"
},
"turn_detection": {
"type": "server_vad"
}
}
},
"provider_params": "{\"key\": \"value\"}"
}
}
| Parameter | Type | Description |
|---|---|---|
session.type | string | Must be transcription. Full realtime sessions are not currently supported. |
session.audio.input.transcription.model | string | An ASR model ID marked as supporting real-time WebSocket in the Model Hub. Audio format and sample rate requirements vary by model. |
session.audio.input.transcription.keywords | string, optional | Comma-separated hotword hints, equivalent to hotwords in the HTTP transcription API. Support depends on the model. |
session.audio.input.format.audio_format | string | Audio encoding. Only PCM formats (pcm* and the wav container) whose duration can be calculated precisely from byte counts are supported. Compressed formats such as opus/flac/aac are rejected because forwarded bytes cannot be used to calculate billable duration. Formats overridden through provider_params have the same restriction. |
session.audio.input.format.sample_rate | integer | Required. Sample rate in Hz; must be a positive integer and meet the selected model's requirements. |
session.audio.input.format.channels | integer | Number of audio channels. The example uses mono (1). |
session.audio.input.turn_detection.type | string, optional | Turn detection mode; see Turn Detection Modes. Set the containing turn_detection object to {"type": "server_vad"} or omit it for automatic detection. Set turn_detection explicitly to null for manual mode. |
session.provider_params | string, optional | A JSON string for model-specific native parameters not covered above, equivalent to provider_params in the HTTP transcription API. If the same parameter is also set through a field above, the value in provider_params takes precedence, except for model. |
input_audio_buffer.append
Send an audio chunk. audio must be a Base64-encoded string of the raw audio bytes.
{
"type": "input_audio_buffer.append",
"audio": "<BASE64_ENCODED_AUDIO_BYTES>"
}
Send approximately 100–200 ms of audio per chunk at the actual audio rate. In server_vad mode, the server handles turn detection; calling commit or clear returns an error. In manual mode, send commit after the audio to receive the final result for that turn.
input_audio_buffer.commit
In manual mode, this event ends the current turn. The Gateway processes the audio previously sent through append as one turn and returns its final result.
{
"type": "input_audio_buffer.commit"
}
This event is only valid in manual mode.
input_audio_buffer.clear
In manual mode, this event discards the current uncommitted audio. The Gateway clears the buffer received since the last commit without producing a transcription result.
{
"type": "input_audio_buffer.clear"
}
This event is only valid in manual mode. Sending it in server_vad mode returns an error. clear is silent: no additional events are returned, and previously completed turns are unaffected.
Server Events
session.created
After the connection is established, the Gateway sends:
{
"event_id": "evt_abc12345_1",
"type": "session.created",
"session": {
"id": "abc12345-...",
"object": "realtime.session"
}
}
session.updated
After configuration succeeds, the Gateway returns the normalized session configuration:
{
"event_id": "evt_abc12345_2",
"type": "session.updated",
"session": {
"id": "abc12345-...",
"object": "realtime.session",
"audio": {
"input": {
"format": {
"audio_format": "pcm",
"sample_rate": 16000,
"channels": 1
},
"transcription": {
"model": "<REQUESTED_MODEL_ID>",
"keywords": "EVA,AutoArk"
},
"turn_detection": {
"type": "server_vad"
}
}
}
}
}
conversation.item.input_audio_transcription.delta
Returns a partial transcription:
{
"event_id": "evt_abc12345_8",
"type": "conversation.item.input_audio_transcription.delta",
"item_id": "item_turn_001",
"content_index": 0,
"delta": "Hello, welcome"
}
Depending on the model, delta may contain either an incremental fragment or the full partial transcript for the current turn. Do not concatenate every delta unconditionally.
Once a turn boundary is detected (by the server in server_vad mode, or by the client's commit in manual mode), the event sequence is committed → completed:
input_audio_buffer.committed
{
"event_id": "evt_abc12345_9",
"type": "input_audio_buffer.committed",
"item_id": "item_turn_001",
"previous_item_id": null
}
conversation.item.input_audio_transcription.completed
{
"event_id": "evt_abc12345_10",
"type": "conversation.item.input_audio_transcription.completed",
"item_id": "item_turn_001",
"content_index": 0,
"transcript": "Hello, welcome to EVA Gateway.",
"usage": {
"duration_ms": 1840
},
"credit": 123
}
error
{
"event_id": "evt_abc12345_11",
"type": "error",
"error": {
"code": "40003",
"type": "client",
"message": "input_audio_buffer.commit is not supported; turns are detected automatically (server_vad)",
"param": null
}
}
Python Example
import asyncio
import base64
import json
import websockets
async def main():
async with websockets.connect(
"wss://eva-gateway.autoarkai.com/v1/realtime",
additional_headers={"Authorization": "Bearer <YOUR_API_KEY>"},
) as ws:
await ws.recv() # session.created
# Configure the session
await ws.send(json.dumps({
"type": "session.update",
"session": {
"type": "transcription",
"audio": {
"input": {
"format": {"audio_format": "pcm", "sample_rate": 16000, "channels": 1},
"transcription": {"model": "<REALTIME_ASR_MODEL_ID>"},
"turn_detection": {"type": "server_vad"},
}
}
}
}))
await ws.recv() # session.updated
# Send 16 kHz mono PCM in 200 ms chunks at the actual audio rate
CHUNK_BYTES = 6400 # 200ms @ 16kHz/16bit/mono
with open("audio.pcm", "rb") as f:
while data := f.read(CHUNK_BYTES):
await ws.send(json.dumps({
"type": "input_audio_buffer.append",
"audio": base64.b64encode(data).decode(),
}))
await asyncio.sleep(0.2)
# Append 2 seconds of silence so server_vad detects the end of the turn and emits completed
SILENCE = b"\x00" * (16000 * 4) # 2 seconds of silence (16 kHz, 16-bit, mono)
for i in range(0, len(SILENCE), CHUNK_BYTES):
await ws.send(json.dumps({
"type": "input_audio_buffer.append",
"audio": base64.b64encode(SILENCE[i:i + CHUNK_BYTES]).decode(),
}))
await asyncio.sleep(0.2)
# Receive transcription results
async for raw in ws:
event = json.loads(raw)
if event["type"] == "conversation.item.input_audio_transcription.delta":
print("Partial:", event["delta"])
elif event["type"] == "conversation.item.input_audio_transcription.completed":
print("Final:", event["transcript"])
break
asyncio.run(main())
Before running this example, replace API_KEY with your key and prepare an audio file that meets the selected model's requirements. The example above uses 16 kHz mono PCM.