Does the API support WebSockets?
Overview
Yes. The WebSocket API provides real-time bidirectional communication for messaging, streaming responses, and presence indicators. Connect to:
wss://api.dyva.ai/v1/ws
Authentication
Authenticate during the initial WebSocket handshake by including your API key as a query parameter:
wss://api.dyva.ai/v1/ws?token=rk_your_api_key
The server validates your key and returns a connected event on success or closes the connection with an error code on failure.
Event Types
The WebSocket connection supports these event types:
message.created — a new message was sent (by you or the character)
message.streaming — character response tokens arriving in real-time
message.completed — the character finished generating its response
typing.start / typing.stop — typing indicators
conversation.updated — conversation metadata changed
error — something went wrong (includes error code and message)
Use Cases
- Chat interfaces — build real-time chat UIs that show streaming responses as the character generates them
- Live dashboards — monitor conversation activity across multiple characters in real-time
- Bots and automations — respond to messages programmatically as they arrive
Connection Limits
- Pro — 50 concurrent WebSocket connections
- Creator — 100 concurrent WebSocket connections
Connections idle for more than 5 minutes without any message exchange are automatically closed. Send periodic ping frames to keep the connection alive.
Full protocol documentation at dyva.ai/docs/websockets.
For simpler integrations that do not need real-time streaming, use the standard REST endpoints instead. The REST API supports long-polling for message retrieval.
Not finding it?
AI answers instantly. Humans follow up within 24 hours.