> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spatius.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Server Error Handling

> Error handling boundaries for the Python, Go, and JavaScript Server SDKs.

All three Server SDKs expose structured errors, but their fields and code coverage differ. Use the types and constants exported by your language's SDK, and retain a fallback for ordinary configuration or transport errors.

## Python

The Python SDK exposes structured `SessionTokenError` and `AvatarSDKError` instances. Use their stable `code` for program logic and log context fields such as failure phase, HTTP status, server details, correlation IDs, and WebSocket close information when present.

The complete field list and `AvatarSDKErrorCode` values live in the [Python SDK error reference](/sdk-reference/python-sdk/python-sdk#error-handling).

## Go

The Go SDK returns `error` values from session operations and sends asynchronous failures to `WithOnError`. Use `errors.As` to inspect `*spatius.AvatarSDKError` when present. It exposes `Code`, `Message`, `Phase`, `ServerCode`, `ConnectionID`, and `ReqID`.

The [Go SDK error reference](/sdk-reference/go-sdk/go-sdk#error-handling) lists supported `ErrorCode...` constants. Token exchange and other failures can be ordinary Go errors; do not assume Python's full field set or classifications exist in Go.

## JavaScript / TypeScript

The Node.js SDK exposes `AvatarSDKError` and its `SessionTokenError` subclass. Handle rejected session-method promises with `try` / `catch`, and asynchronous runtime failures with `onError`.

Use `error.code` and `AvatarSDKErrorCode` for program logic. Context fields use camelCase, including `httpStatus`, `serverCode`, `serverDetail`, `connectionId`, `reqId`, `closeCode`, and `closeReason`. Configuration and lifecycle misuse can throw ordinary JavaScript errors. See the [JavaScript SDK error reference](/sdk-reference/javascript-sdk/javascript-sdk#error-handling).

## Recovery policy

| Failure area | Recommended handling |
| - | - |
| Credentials or application configuration | Stop retrying and surface the problem to operators. |
| Session Token creation | Check API Key, App ID, expiry, account state, and selected region. |
| WebSocket connection | Retry transient network failures with bounded exponential backoff. |
| Audio or request validation | Fix the payload before retrying. |
| Unexpected runtime close | Log close details and correlation IDs, then create a new session if retryable. |
| Repeated upstream or server failure | Stop the retry loop and alert operators or contact Spatius support. |

Never log the API Key or complete Session Token while collecting diagnostic context.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.