Errors
How errors are reported
Streaming reports problems on the WebSocket in two ways:
- An
Errormessage, sent immediately before the server closes the connection. - A WebSocket close code, which identifies the cause.
Decide what to do based on the close code, not the message text. The text is for people and may change. The exceptions are insufficient_credits, api_key_revoked, initial_timeout and idle_timeout, which are stable values.
Every Error closes the connection. There are no non-fatal errors on this endpoint.
Speech to Text and Text to Speech use different close codes. For example, an invalid API key closes a Speech to Text connection with 4001 and a Text to Speech WebSocket with 1008. For Text to Speech errors, see Errors & Warnings.
File transcription returns HTTP statuses. Those are listed after the streaming close codes.
Close codes
A WebSocket request to an unknown path is rejected with HTTP 404 before the connection opens.
Low balance warning
When your balance reaches the warning threshold, the server sends one QuotaWarning message per session. This is not an error: the stream keeps running until credits run out (close 4005) or you close it.
remaining_funds is your remaining workspace balance in USD.
Recommended handling
Contacting support
Include the following in your support request:
- the
rawEvent.request_idfrom anypartialorfinalmessage on the connection - the close code and the
messagetext - the host you connected to
- the approximate time of the session
If the connection closed before any partial or final message (for example an auth failure with code 4001), there is no request_id. Include the time of the attempt, the host, how you sent the key, and the close code.
File transcription
File transcription returns an HTTP status. Branch on the status and, when the body includes one, on detail.code or error.code. Message text can change.
If the server has already sent the 200 headers for a long job, the same detail object arrives in that body. Check for detail before you read the transcript. When the synchronous wait reaches 600 seconds, the body includes the transcription_id and the job keeps running:
Poll that id. See Synchronous response.
A webhook or poll that fails uses error.code. A completed job can also include warnings.
Audio with no speech is a completed transcript with an empty text. It is not one of these codes. Delivery and retry behaviour is on File transcription.