WebSocket Endpoint
Connect to the MedAssist WebSocket for real-time medical consultations:
Replace <session-id> with the session ID obtained from the Create Session API.
Authentication
After establishing the WebSocket connection, authenticate using the session token:
Message Types
Text Messages
Send text-based medical queries:
Audio Messages
Send base64-encoded audio for voice consultations:
File Upload
File uploads require a two-step process:
Step 1: Request presigned URL
Step 2: Send file URL after upload
Message Fields
Event type. Use “auth” for authentication, “chat” for messages
Content type. Options: “text”, “audio”, “file”
Timestamp in milliseconds
Unique message identifier
Message payload containing the actual content
Example Implementation
Error Handling
The WebSocket may return error messages for various scenarios:
- Authentication failure: Invalid or expired token
- Invalid message format: Malformed JSON or missing required fields
- Rate limiting: Too many messages sent in a short period
- Session expired: Session has exceeded its lifetime
Always implement proper error handling and reconnection logic in your WebSocket client.