Documentation/WebSocket / Real-Time

WebSocket / Real-Time

WebSocket / Real-Time

MeeDoo provides a WebSocket interface for real-time, bidirectional communication using Socket.IO. This is ideal for chat applications, live dashboards, and interactive AI experiences.

Connection

Connect to wss://api.meedoo.co/ws and authenticate by passing your API key in the handshake:

const socket = io('https://api.meedoo.co/ws', {
  auth: { token: API_KEY }
});

Event Types

EventDirectionDescription
chat:completionClient → ServerSend a chat completion request
chat:message:deltaServer → ClientStreaming delta chunk from the model
chat:completion:doneServer → ClientCompletion finished
user-joinServer → ClientA user joined the room
heartbeatBi-directionalKeep-alive ping (every 25s)

Rooms

Join specific rooms to receive targeted events. Use socket.emit('join', { room: 'my-room' }) to join a room.

Reconnection

Socket.IO handles automatic reconnection with exponential backoff. Configure reconnection attempts and delays in the connection options.

WS /ws

WebSocket Connection

Establish a WebSocket connection for real-time communication. Authenticate by passing your API key as a token in the handshake.

Response Examples

WebSocket Message
{
  "type": "chat:completion",
  "id": "md-resp-abc123",
  "model": "meedoo:latest",
  "choices": [
    {
      "delta": {"content": "Hello!"}
    }
  ]
}

Code Examples

WebSocket Connection
curl -i -N -H "Connection: Upgrade" \
  -H "Upgrade: websocket" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.meedoo.co/ws