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
| Event | Direction | Description |
|---|---|---|
chat:completion | Client → Server | Send a chat completion request |
chat:message:delta | Server → Client | Streaming delta chunk from the model |
chat:completion:done | Server → Client | Completion finished |
user-join | Server → Client | A user joined the room |
heartbeat | Bi-directional | Keep-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
{
"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