Error Handling

This page covers HTTP status codes, media errors, stream errors, and common troubleshooting scenarios for the RAVATAR API.

HTTP Status Codes

These HTTP errors can occur across all API endpoints:

StatusNameDescriptionRecommended Handling
200OKRequest successfulProcess response normally
402Payment RequiredSubscription or payment issueShow upgrade/payment prompt to user
403ForbiddenJWT token expired or invalidRefresh token via POST /jwt and retry request (see Token Refresh)
503Service UnavailableAll AI assistants busyShow "Please try again later" message
504Gateway TimeoutConnection timeoutRetry with exponential backoff

Media Errors

These errors may occur when accessing microphone or camera:

Error CodeDescriptionRecommended Handling
permission_deniedUser denied microphone permissionShow permission request dialog with instructions
no_specified_media_foundRequested media device not foundShow "No microphone found" message
media_in_useMedia device used by another appShow "Microphone in use" message
invalid_media_constraintsAudio constraints not supportedFall back to default constraints
no_constraintsNo media constraints specifiedUse default audio constraints
recorder_errorMediaRecorder errorRestart recording or show error
media_abortedRecording was abortedAllow user to retry

Stream Errors

These errors may occur during Live Mode streaming:

ErrorMessageDescriptionRecommended Handling
Stream Error"Something went wrong"Generic stream errorEnd session and prompt to reconnect
Timeout"Connection timeout"Stream connection timed outRetry connection
Busy"All AI assistants are busy at the moment"No available streaming slotsShow busy message, offer retry later
Expired"Session expired"Live session ended server-sideClear LicenseId, prompt to start new session

Troubleshooting

Failed to get JWT token

Cause: Invalid API URL or network issue.

Solution:

  • Verify your API URL is correct (https://chat.rvtr.ai)
  • Check your internet connection
  • Enable debug logging to see detailed error messages

Failed to load connection

Cause: JWT token expired or invalid.

Solution:

  • Obtain a new JWT token via POST /jwt (see Authentication)
  • Ensure you received a valid JWT successfully before loading connection data

WebSocket connection fails

Cause: Invalid JWT token or WebSocket URL.

Solution:

  • Verify the WebSocket URL is wss://chat.rvtr.ai/ws/chat?token=YOUR_TOKEN
  • Ensure the JWT token is valid (refresh if needed)
  • Check browser console for WebSocket errors
  • See Reconnection Logic for automatic retry implementation

Payment required error (402)

Cause: Account has insufficient balance or payment issue.

Solution: Check your RAVATAR account balance and payment status in the dashboard.

Messages not sending

Cause: WebSocket not connected or missing required fields.

Solution:

  • Ensure WebSocket connection is established
  • Verify avatar and language are selected from the configuration response
  • Check browser console for errors
  • Confirm all required message fields are present (see Chat Mode or Live Mode)

PixelStreaming iframe shows a black screen

Cause: The PixelStreaming page is blocking iframe embeds, or there is a mixed content issue.

Solution:

  • Open the streaming URL in a new browser tab. If it works there but not in the iframe, check your browser DevTools Console for X-Frame-Options or frame-ancestors errors. This requires a server-side configuration change.
  • If your application is served over HTTPS, ensure the streamingUrl is also HTTPS. Mixed content is blocked by modern browsers.

Enable debug mode

To see detailed logging of all API and WebSocket events:

  1. Set VITE_DEBUG_LOGS=true in your environment configuration
  2. Restart the development server
  3. Open browser console (F12)
  4. All HTTP requests, WebSocket connection events, message sending/receiving, and error details will be logged

Audio Format Comparison

PropertyStandard (Blob)Gemini Native (PCM)
Use CaseChat ModeLive Mode (Gemini API)
FormatWAV / WebMRaw PCM
Sample Rate16 kHz16 kHz
Bit DepthVaries16-bit signed integer
ChannelsMonoMono
Byte OrderN/ALittle-endian
ProcessingMediaRecorder APIAudioWorklet / raw capture
Buffer SizeContinuous4,096 samples
Transmission Fieldfile_base64_dataaudio_base64_pcm
EncodingBase64Base64

Glossary

TermDefinition
AvatarA virtual AI assistant with a visual representation (video/animated) that responds to user messages.
Chat ModeStandard asynchronous messaging mode where avatar responses are pre-rendered and delivered as video/audio files.
JWT (JSON Web Token)A secure token used for API authentication, containing encoded user and session information.
LicenseIdA unique identifier for an active Live Mode session, required for all real-time streaming operations.
Live ModeReal-time interactive mode with streaming avatar responses via PixelStreaming technology.
PCM (Pulse-Code Modulation)Raw, uncompressed audio format used for real-time audio streaming in Live Mode.
PixelStreamingUnreal Engine technology for streaming real-time rendered content to browsers and mobile devices.
Push-to-TalkAudio input mode where users manually start/stop recording, as opposed to automatic Voice Activity Detection.
SessionA unique identifier for a user's conversation context, obtained from the /connection endpoint.
VAD (Voice Activity Detection)Automatic detection of speech in audio input, used to determine when users start/stop speaking.
WebSocketA protocol for bidirectional, real-time communication between client and server.