Errors and troubleshooting
Error response
Failed HTTP requests return a non-2xx status with a JSON error:
HTTP errors
These errors apply to HTTP requests and failed WebSocket handshakes.
For transient failures, increase the delay between retries and add a small random delay to avoid simultaneous retries. Set a maximum retry count. See Rate limits for concurrency policies.
Inspect a cURL error
If the TTS quickstart request fails, rerun it without --fail and --output speech.wav to display the JSON error in your terminal.
WebSocket failures
After a successful handshake, WebSocket errors are sent as JSON before the close frame when possible. STT uses an error event:
Use error.code to handle STT errors and error.requestId to find the connection in Request logs. The close code appears there as WS <code>.
STT close codes
Invalid language, prompt, VAD settings, or unknown session fields can return UPSTREAM_UNAVAILABLE during setup. Check your session arguments before retrying.
Insufficient credits for STT
STT requires enough credit for the next 36 seconds of audio, but charges only for audio accepted. A positive balance may still be too low to continue.
On INSUFFICIENT_CREDITS, stop sending audio, keep completed transcripts, and add credits before reconnecting. The connection closes with code 1008. See Usage and billing for charging rules.
TTS input streaming errors
TTS uses a flat JSON error:
Handle the string error field. Keep x-request-id from the handshake; some error messages omit requestId.
See TTS input streaming for supported options.
Interrupted streams
TTS HTTP: Check the HTTP status before treating the body as audio. A failure after streaming starts can interrupt the audio without a JSON error. Treat a failed read as incomplete delivery. Retrying generates the full text again; there is no resume offset.
TTS input streaming: If the connection ends before isFinal: true, treat the audio as incomplete. Reconnect to start a new request; there is no resume offset. Check Request logs for completed segments before resending text, since resending them can incur another charge.
STT: Reconnect, authenticate, and send a new session configuration. Keep completed transcripts already received. If you retained the audio for unfinished utterances, you can resend it; it receives new IDs and is not automatically deduplicated. Only a received transcript.completed event confirms a final transcript.