For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages can be requested by appending `.md` to the URL, or by setting the `Accept` header to `text/markdown`.
Skip to main content
Transcription API

Agent STT

WSS 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:

GroupMessagesWhat they mean
Speech signalsSpeechStarted, SpeechEndedVoice activity. Sent in vad mode only, and not turn boundaries — a mid-sentence pause ends speech without ending the turn.
SegmentsAddPartialSegment, AddSegmentThe transcript. Each partial is a snapshot that replaces the last; AddSegment is final and will not change.
Turn signalsStartOfTurn, EndOfTurnWhere a speaker's turn starts and ends. EndOfTurn is the turn's last message, and the cue for your agent to respond.

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 the Authorization header — 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=

Send client → server

StartRecognition

Initiates a new recognition session.

audio_format
AudioFormat
message
"StartRecognition"
transcription_config
TranscriptionConfigno additional propertiesextends SpeakerDiarizationConfigRule
turn_config
TurnConfigno additional properties
optional

AddAudio

A binary chunk of audio. The server confirms receipt by sending an AudioAdded message.

application/octet-stream
AddAudio

EndOfStream

Declares that the client has no more audio to send.

last_seq_no
integer
message
"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_config
MidSessionTranscriptionConfigno additional properties

GetSpeakers

Requests any detected speaker identifiers to be returned.

final
boolean
optional
message
"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"
timestamp
number<float>≥ 0

Timestamp 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 server → client

RecognitionStarted

Server response to StartRecognition, acknowledging that a recognition session has started.

id
string
language_pack_info
LanguagePackInfono additional properties
optional

Properties of the language pack.

message
"RecognitionStarted"
orchestrator_version
string
optional

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_no
integer≥ 0

AddPartialSegment

An interim, best-guess preview of the segment currently being built. Subject to change.

message
"AddPartialSegment"
metadata
SegmentMetadatano additional properties
segment
Segmentno additional properties

AddSegment

A finalized, stable segment, sent when a segment boundary is reached. It will not change.

message
"AddSegment"
metadata
SegmentMetadatano additional properties
segment
Segmentno additional properties

SpeechStarted

Sent when voice activity detection detects the onset of speech.

message
"SpeechStarted"
metadata
SpeechStartedMetadatano additional properties

SpeechEnded

Sent when voice activity detection detects the end of speech.

message
"SpeechEnded"
metadata
SpeechEndedMetadatano additional properties

StartOfTurn

Sent when turn detection marks the start of a speaker turn.

message
"StartOfTurn"
metadata
StartOfTurnMetadatano additional properties

EndOfTurn

Sent when turn detection marks the end of a speaker turn. It is the last message of a turn.

message
"EndOfTurn"
metadata
EndOfTurnMetadatano 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"
reason
string
type
enum10 values

Warning

Warning messages sent from the server to the client.

duration_limit
number≥ 0
optional
message
"Warning"
reason
string
type
enum"duration_limit_exceeded""idle_timeout""session_timeout""add_audio_after_eos""speaker_id""unsupported_language"
optional

Info

Additional information sent from the server to the client.

message
"Info"
optional
quality
"broadcast"
optional
reason
string
optional
type
"recognition_quality" | "concurrent_session_usage"
optional

SpeakersResult

Server response to GetSpeakers, returning any detected speaker identifiers.

message
"SpeakersResult"
speakers
object[]

Connection close​

An Error message can be followed by a WebSocket close frame. Its code, and the reason it carries:

Close codeReason
1003protocol_error
1008policy_violation
1011internal_error
4001not_authorised
4003not_allowed
4004invalid_model
4005quota_exceeded
4006timelimit_exceeded
4013job_error

For 4005, 4013 and 1011 only, retry after at least 5–10 seconds.

Session