Session — which messages pass, in order
Agent STT
wss://global.rt.speechmatics.com/v2/agent/Transcribe a conversation as it happens, for a voice agent, over one WebSocket connection. Open the connection and send StartRecognition, then stream audio as binary messages. Every other message is a JSON object that names itself in its message field.
Three groups of server messages carry the conversation itself, and are the ones your agent logic acts on:
Pass AddSegment downstream to your LLM, and use AddPartialSegment only for display. The other server messages manage the session rather than the conversation.
Handshake
- GET
wss://global.rt.speechmatics.com/v2/agent/
Routes each connection to the nearest region, for the lowest latency. To keep data in one region instead, connect to that region's endpoint, such as wss://eu.rt.speechmatics.com/v2/agent. See Supported endpoints.
Authentication
Any one of:
- apiKey
Authorization: Bearer <token>Your API key, for server-side connections.
- temporaryKey
?jwt=<key>A Realtime (
type=rt) temporary key, for connections from a browser, which cannot set theAuthorizationheader — and should not hold your long-lived API key. For example,wss://global.rt.speechmatics.com/v2/agent?jwt=<temporary-key>.
Responses
Switching Protocols. Connected: send StartRecognition to begin.
A successful handshake request:
GET /v2/agent HTTP/1.1
Host: eu.rt.speechmatics.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: ujRTbIaQsXO/0uCbjjkSZQ==
Sec-WebSocket-Version: 13
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Authorization: Bearer wmz9fkLJM6U5NdyaG3HLHybGZj65PXp
User-Agent: Python/3.12 websockets/15.0
And its response:
HTTP/1.1 101 Switching Protocols
Connection: upgrade
Upgrade: WebSocket
Sec-WebSocket-Accept: 87kiC/LI5WgXG52nSylnfXdz260=
Bad Request. The handshake request is malformed.
Unauthorized. The API key or temporary key is not valid.
Method Not Allowed. The request method is not GET.
Send
StartRecognition
Initiates a new recognition session.
audio_formatAudioFormatmessage"StartRecognition"transcription_configTranscriptionConfigno additional propertiesextendsSpeakerDiarizationConfigRuleturn_configoptionalTurnConfigno additional properties
AddAudio
A binary chunk of audio. The server confirms receipt by sending an AudioAdded message.
application/octet-streamAddAudio
EndOfStream
Declares that the client has no more audio to send.
last_seq_nointegermessage"EndOfStream"
SetRecognitionConfig
Allows the client to re-configure the recognition session.
The language field can be included in SetRecognitionConfig, but its value must match the language specified in the initial StartRecognition message.
Attempting to change the language or any other transcription configuration parameter not listed below will result in an error.
message"SetRecognitionConfig"transcription_configMidSessionTranscriptionConfigno additional properties
GetSpeakers
Requests any detected speaker identifiers to be returned.
finaloptionalbooleanmessage"GetSpeakers"
ForceEndOfUtterance
Closes the current speaker turn. The transcript up to timestamp is flushed as an AddSegment, followed by EndOfTurn.
Supported only with turn_config.turn_detection_mode: external, where the client detects turn ends itself.
In the default vad mode the service closes turns from voice activity.
message"ForceEndOfUtterance"timestampnumber<float>≥ 0Timestamp of the audio data that corresponds to the force end of utterance request. It's the number of seconds since the beginning of the audio.
Receive
RecognitionStarted
Server response to StartRecognition, acknowledging that a recognition session has started.
idstringlanguage_pack_infooptionalLanguagePackInfono additional propertiesProperties of the language pack.
message"RecognitionStarted"orchestrator_versionoptionalstring
AudioAdded
Server response to AddAudio, indicating that audio has been added successfully.
When clients send audio faster than real-time, the server may read data slower than it's sent. If binary AddAudio messages exceed the server's internal buffer, the server will process other WebSocket messages until buffer space is available. Clients receive AudioAdded responses only after binary data is read. This can fill TCP buffers, potentially causing WebSocket write failures and connection closure with prejudice. Clients can monitor the WebSocket's bufferedAmount attribute to prevent this.
message"AudioAdded"seq_nointeger≥ 0
AddPartialSegment
An interim, best-guess preview of the segment currently being built. Subject to change.
message"AddPartialSegment"metadataSegmentMetadatano additional propertiessegmentSegmentno additional properties
AddSegment
A finalized, stable segment, sent when a segment boundary is reached. It will not change.
message"AddSegment"metadataSegmentMetadatano additional propertiessegmentSegmentno additional properties
SpeechStarted
Sent when voice activity detection detects the onset of speech.
message"SpeechStarted"metadataSpeechStartedMetadatano additional properties
SpeechEnded
Sent when voice activity detection detects the end of speech.
message"SpeechEnded"metadataSpeechEndedMetadatano additional properties
StartOfTurn
Sent when turn detection marks the start of a speaker turn.
message"StartOfTurn"metadataStartOfTurnMetadatano additional properties
EndOfTurn
Sent when turn detection marks the end of a speaker turn. It is the last message of a turn.
message"EndOfTurn"metadataEndOfTurnMetadatano additional properties
EndOfTranscript
Server response to EndOfStream, sent after the server has finished sending all segment messages.
message"EndOfTranscript"
Error
Error messages sent from the server to the client. After any error, transcription is terminated and the connection is closed.
message"Error"reasonstringtypeenum10 values
Warning
Warning messages sent from the server to the client.
duration_limitoptionalnumber≥ 0message"Warning"reasonstringtypeoptionalenum"duration_limit_exceeded""idle_timeout""session_timeout""add_audio_after_eos""speaker_id""unsupported_language"
Info
Additional information sent from the server to the client.
messageoptional"Info"qualityoptional"broadcast"reasonoptionalstringtypeoptional"recognition_quality" | "concurrent_session_usage"
SpeakersResult
Server response to GetSpeakers, returning any detected speaker identifiers.
message"SpeakersResult"speakersobject[]
Connection close
An Error message can be followed by a WebSocket close frame. Its code, and the reason it carries:
For 4005, 4013 and 1011 only, retry after at least 5–10 seconds.