Errors
The error envelope
Section titled “The error envelope”Every application-level error — bad requests, auth failures, missing resources, rate limits, upstream failures — is returned as JSON with a non-2xx status code, in one consistent envelope:
{ "error": { "type": "not_found", "code": "no_such_avatar", "message": "Avatar not found or not ready.", "request_id": "req_5f3a1c9e2b7d" }}| Field | Description |
|---|---|
type | Broad error category. Stable, safe to branch on in code. |
code | Specific machine-readable reason within that category. Stable. |
message | Human-readable explanation. Don’t parse this; it can change wording without notice. |
request_id | Unique ID for this request, also returned as the x-request-id response header. Include it when contacting support. |
Branch on the HTTP status code and error.type (and error.code where you need finer granularity), never on the exact text of message.
Error types and codes
Section titled “Error types and codes”| HTTP | error.type | error.code | Meaning |
|---|---|---|---|
| 401 | authentication | missing_key | No Authorization: Bearer sk_... header was sent. |
| 401 | authentication | invalid_key | The key is unknown or has been revoked. |
| 404 | not_found | no_such_session | The session doesn’t exist, or isn’t yours. |
| 404 | not_found | no_such_avatar | No such avatar id for your key, or the owner has not exposed it to the API. |
| 404 | not_found | livekit_not_enabled_for_avatar | The avatar exists but is not ready on LiveKit, so it can’t be minted. |
| 404 | not_found | livekit_profile_not_allowed | The avatar’s LiveKit profile is not allowed for your key. |
| 409 | conflict | session_ended | The session has already ended. Create a new one. |
| 403 | permission | verbatim_not_enabled | You asked for "verbatim": true, and this avatar is not enabled for verbatim speech for your account. See Bring your own brain. |
| 409 | invalid_request | not_available_on_livekit | The endpoint does not work on LiveKit sessions: /speak, /audio, /interrupt, /token, /waiting_state. The avatar’s own brain and voice reply to turns on lk.chat; to make it say your exact words, create the session with "verbatim": true and send lines on lk.say. |
| 410 | invalid_request | transport_retired | You asked for "transport": "mse-ws". That transport is retired; omit transport or send "livekit". |
| 422 | invalid_request | invalid_body | The request body is missing or not valid JSON. |
| 422 | invalid_request | unknown_transport | transport is not a value the gateway knows. Omit it or send "livekit". |
| 422 | invalid_request | mode_not_available | The requested mode isn’t available for this avatar. |
| 422 | invalid_request | invalid_verbatim | verbatim is not true or false, or it was sent with a transport other than livekit. |
| 429 | rate_limit | concurrency_cap | You’re at your key’s concurrent-session limit. |
| 429 | rate_limit | platform_busy | The platform as a whole is at capacity. Retry shortly. |
| 429 | rate_limited | livekit_rate_limited | The LiveKit session broker is rate limiting. The broker’s Retry-After is passed through (60 seconds if the broker sent none). |
| 500 | server | internal_error | Something went wrong on our end. Safe to retry with backoff. |
| 501 | invalid_request | voice_cloning_unavailable | POST /v1/voices is not available. Avatars speak in the voice set in 2wai Studio. |
| 502 | server | livekit_broker_unreachable / livekit_broker_error / livekit_broker_invalid_response | The LiveKit session broker was unreachable, failed, or answered with something unusable. Retry with backoff. |
| 502 | server | upstream_unavailable | An upstream service the gateway depends on was unavailable. Retry with backoff. |
| 502 | upstream | gen_unreachable / gen_server_error / gen_unexpected_status | Catalog hydrate (GET /v1/avatars/{owner}/{name}) could not get a usable answer from the avatar catalog. Retry with backoff. |
| 503 | server | livekit_not_configured | LiveKit is not configured on the gateway. Retry later; contact support if it persists. |
| 503 | server | verbatim_unavailable | The session service could not grant verbatim speech right now. Retry, or create the session without verbatim. |
| 504 | upstream | gen_timeout | Catalog hydrate timed out waiting for the avatar catalog. Retry with backoff. |
Codes from endpoints not available on LiveKit
Section titled “Codes from endpoints not available on LiveKit”These belong to endpoints that answer 409 not_available_on_livekit or 501 voice_cloning_unavailable on the current gateway. You should not see them in a LiveKit integration; they are listed so an older log line still makes sense.
| HTTP | error.type | error.code | Meaning |
|---|---|---|---|
| 404 | not_found | no_such_voice | No such voice id. |
| 404 | not_found | no_such_file | No such file id. |
| 404 | not_found | no_such_waiting_state | The named waiting state isn’t configured for this avatar. |
| 409 | conflict | stream_not_connected | Retired transport only: no client was attached to the session’s stream yet. |
| 422 | invalid_request | empty_text | text was empty. |
| 422 | invalid_request | empty_audio | The audio chunk contained no samples. |
| 422 | invalid_request | chunk_too_large | The audio chunk exceeded the per-chunk limit. |
| 422 | invalid_request | file_too_large | The uploaded file exceeded the size limit. |
| 422 | invalid_request | missing_name | A required name was not supplied. |
| 422 | invalid_request | missing_source | Neither a file_id nor a url was supplied. |
| 422 | invalid_request | voice_too_quiet | The reference audio’s level was too low to clone from. |
| 422 | invalid_request | voice_unprocessable | The reference audio couldn’t be decoded or processed. |
| 502 | server | muse_error / muse_unreachable | The rendering stack failed or was unreachable. |
| 503 | server | voices_degraded / files_degraded | That subsystem is temporarily unconfigured or unavailable. |
Retries
Section titled “Retries”Every 429 carries a Retry-After header (10 seconds for concurrency_cap and platform_busy; for livekit_rate_limited it is whatever the LiveKit broker sent, or 60). Honour it rather than retrying immediately: retrying in a tight loop will keep you capped.
concurrency_cap: you’re at your own limit. End a session you no longer need, or wait for one to finish.platform_busy: the platform as a whole is saturated. Back off and retry.livekit_rate_limited: the LiveKit broker is throttling session creation. Back off forRetry-After.
500, 502 and 504 are safe to retry with exponential backoff. 503 means a subsystem is degraded; retry, but expect it to persist until the subsystem is restored. 4xx responses other than 429 will not succeed on retry: fix the request.
- Limits & concurrency for the specific case of
429s.