Skip to main content
wscat -c "wss://api.gradium.ai/api/speech/asr" \
  -H "x-api-key: YOUR_API_KEY"
wscat -c "wss://api.gradium.ai/api/speech/asr" \
  -H "x-api-key: YOUR_API_KEY"

Lifecycle

{"type":"setup","model_name":"default","input_format":"pcm","json_config":{"language":"en"}}
{"type":"audio","audio":"base64_encoded_audio"}
{"type":"flush","flush_id":1}
{"type":"end_of_stream"}
The server responds with ready, then text, end_text, step, and flushed messages as available, and finally end_of_stream. See WebSocket Lifecycle for connection behavior, reusable sockets, browser tokens, and errors.

Client Messages

setup

FieldTypeRequiredDescription
typestringYesAlways "setup".
model_namestringNoModel alias, defaults to "default".
input_formatstringNopcm, wav, opus, ulaw_8000, alaw_8000, or explicit PCM rates such as pcm_16000. Defaults to wav.
json_configobject or stringNoAdvanced STT settings. See Transcription Settings.
client_req_idstringNoCorrelates multiplexed requests.
close_ws_on_eosbooleanNoDefaults to true; set false to keep the socket open.
retry_for_snumberNoOptional setup retry window in seconds.

audio

FieldTypeRequiredDescription
typestringYesAlways "audio".
audiostringYesBase64-encoded audio chunk.
client_req_idstringNoRequired when routing a multiplexed request.

flush

FieldTypeRequiredDescription
typestringYesAlways "flush".
flush_idintegerYesEchoed in the matching flushed response.
client_req_idstringNoRequired when routing a multiplexed request.

end_of_stream

FieldTypeRequiredDescription
typestringYesAlways "end_of_stream".
client_req_idstringNoEnd the matching multiplexed request.

Server Messages

ready

FieldTypeDescription
typestringAlways "ready".
request_idstringGradium request ID for logging and support.
model_namestringRequested model alias.
sample_rateintegerInput sample rate after setup.
frame_sizeintegerFrame size in samples.
delay_in_framesintegerModel delay, in 80 ms frames.
text_stream_namesstring[]Named text streams, when present.
client_req_idstringPresent for multiplexed requests.

text

FieldTypeDescription
typestringAlways "text".
textstringTranscribed text segment.
start_snumberSegment start time in seconds.
stream_idintegerStream identifier, when present.
client_req_idstringPresent for multiplexed requests.

end_text

FieldTypeDescription
typestringAlways "end_text".
stop_snumberStop time for the previous text segment.
stream_idintegerStream identifier, when present.
client_req_idstringPresent for multiplexed requests.

step

FieldTypeDescription
typestring"step" or legacy "vad".
vadobject[]Horizon predictions with horizon_s and inactivity_prob.
step_idxintegerStep index.
step_duration_snumberStep duration in seconds, usually 0.08.
total_duration_snumberAudio duration processed so far.
client_req_idstringPresent for multiplexed requests.

flushed

FieldTypeDescription
typestringAlways "flushed".
flush_idintegerThe flush_id from the matching request.
client_req_idstringPresent for multiplexed requests.

Terminal messages

TypeDescription
end_of_streamThe request is complete.
errorTerminal error message; the socket closes after the error.
Error
{"type":"error","message":"Error description","code":1008}

Headers

x-api-key
string
required

Your Gradium API key

Response

101

WebSocket connection established