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 Free tier and rate limits for allowance and 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, STT reports errors as an error event before closing the connection:
Use error.code to identify the cause. error.requestId matches the handshake’s x-request-id.
WebSocket close codes
Network failures may close the connection without an error event. In that case, inspect the close code.
Interrupted streams
TTS: 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.
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.