Server → Client Events (WebSocket)
This document describes runtime events emitted by wss://chat-proxy.bitseek.ai/v2/chat.
Event Envelope
All messages are JSON:
{
"event": "event-name",
"data": {}
}
Chat Stream Events
message
Primary event for streaming generated content.
| Field | Type | Description |
|---|---|---|
data.ok |
boolean |
true for normal chunks |
data.conversationId |
string |
Conversation id |
data.messageId |
string |
Message id |
data.output |
string |
Delta text |
data.tokens |
number |
Token estimate for current chunk |
data.stop |
boolean |
true on final chunk |
Chunk example:
{
"event": "message",
"data": {
"ok": true,
"conversationId": "conv-123",
"messageId": "msg-456",
"output": "Hello",
"tokens": 1,
"stop": false
}
}
Final chunk example:
{
"event": "message",
"data": {
"ok": true,
"conversationId": "conv-123",
"messageId": "msg-456",
"output": "",
"tokens": 0,
"stop": true
}
}
conv-message
Sent before generation to provide conversation metadata.
| Field | Type | Description |
|---|---|---|
data.ok |
boolean |
Success flag |
data.conversationId |
string |
Conversation id |
data.messageId |
string |
Message id |
data.timestamp |
number |
Server timestamp (ms) |
Lifecycle Events
auth-connect-complete
Authentication and downstream connection setup completed.
set-model-complete
Model setup completed for current connection context.
pong
Heartbeat response for client ping.
Error Event
error
Error payload followed by server-side socket close.
| Field | Type | Description | |
|---|---|---|---|
data.ok |
false |
Failure marker | |
data.code |
number |
Error code (see docs/error.md) |
|
data.error |
string |
Error message | |
data.clientId |
`string \ | undefined` | Current client id |
data.timestamp |
number |
Server timestamp (ms) |
Example:
{
"event": "error",
"data": {
"ok": false,
"code": 4002,
"error": "Prompt is required",
"clientId": "xxxx",
"timestamp": 1739765563421
}
}
Typical Flow
- Connect with
apikeyortoken. - Receive
auth-connect-complete. - Send
genrequest. - Receive
conv-message. - Receive one or more
messagechunks (stop: false). - Receive final
message(stop: true).