Skip to main content
All Lokutor API errors follow a single structured format:

Authentication Errors

Errors that indicate the client cannot authenticate. Do not retry these without user intervention.
Authorization: Bearer support varies by endpoint. /tts/synthesize, /stt/transcribe, and /denoise accept Authorization: Bearer, a raw Authorization header, X-API-Key, or ?api_key=. Every other authenticated endpoint (including the entire Call Center API) only accepts X-API-Key or ?api_key= — a Bearer token there is silently ignored and the request gets treated as unauthenticated. When in doubt, send X-API-Key; it works everywhere.
SDK handling:

Validation Errors

Errors that indicate the request was malformed. Fix the request payload and retry.

TTS Errors

Errors during text-to-speech synthesis. Most are retryable.

STT Errors

Errors during speech-to-text transcription.

Agent Errors

Errors during voice agent session management.

Billing Errors

Usage is paid from a prepaid balance (Pricing and billing). These errors mean the account cannot pay for what was asked; none of them goes away by retrying. Where they arrive:
  • REST (/tts/synthesize, /stt/transcribe, /denoise): in the error format above.
  • Call Center API: as {"code": "billing.topup_required", "error": "…"}, with the same codes.
  • WebSocket (/ws/agent, /ws/tts, /ws/stt): the refusal comes before the connection opens. The handshake answers 402 with the message as plain text; a browser WebSocket only sees the connection fail (close code 1006), so check the balance when a connection fails at the handshake.
A call already in progress is not cut with an error when the balance runs out: the agent says goodbye and hangs up once the account is $2 below zero, and on the web the socket then closes with 1008 and the reason account balance exhausted. See When the balance runs out.

Internal Errors

Catch-all errors for unexpected server-side failures.

Client-side (JavaScript SDK)

These are raised by @lokutor/sdk in the browser, not sent by the server.

WebSocket Close Codes

When the connection closes, the WebSocket close code provides additional context:

Retry Strategy

Use this decision tree for every error:

Custom Retry Logic

If you are not using the SDK’s built-in reconnection: