Skip to main content

WebSocket API

The WebSocket API enables real-time, streaming chat with your Biel.ai project. Use it when you need token-by-token AI responses instead of waiting for the full response via the REST API.

Endpoint: wss://app.biel.ai/ws/messages/{projectId}

To continue an existing chat: wss://app.biel.ai/ws/messages/chat/{chatId}

Connect

Open a WebSocket connection to:

wss://app.biel.ai/ws/messages/{projectId}

Replace {projectId} with your project slug (e.g., jfvzioa17q).

Send a message

Send a JSON message to the WebSocket:

{
"projectId": "your-project-slug",
"from": "user",
"message": "How do I authenticate?",
"url": "https://docs.example.com/auth",
"email": "user@example.com"
}
FieldTypeRequiredDescription
projectIdstringYesProject slug.
fromstringYesAlways "user".
messagestringYesThe user's message (max 1000 characters, Markdown supported).
chatIdstringNoChat session UUID. Omit for the first message — included in the AI response.
urlstringNoPage URL where the chat is happening. Used for domain validation.
emailstringNoEmail or ID for conversation tracking.
apiKeystringNoAPI key with chat_create permission. Required for private projects.
thinkModebooleanNoEnable reasoning mode for deeper analysis.
metadatastringNoTag to identify the conversation source.

Receive a response

The server sends JSON messages back. Partial messages stream token-by-token; the final message includes sources.

{
"projectId": "your-project-slug",
"chatId": "550e8400-e29b-41d4-a716-446655440000",
"from": "ai",
"messageId": "msg-uuid",
"message": "To authenticate, use the...",
"timestamp": "2026-01-15T10:30:00Z",
"isPartial": false,
"sources": [
{
"title": "Authentication guide",
"url": "https://docs.example.com/auth"
}
]
}
FieldTypeDescription
projectIdstringProject slug.
chatIdstringChat session UUID. Use this in subsequent messages to continue the conversation.
fromstringAlways "ai".
messageIdstringMessage UUID.
messagestringAI response content (Markdown).
timestampstringISO 8601 timestamp.
isPartialbooleantrue for streaming tokens, false for the final message.
sourcesarraySource references (only in final message). Each has title and url.
incompletebooleantrue if the response was cut short due to token limits. Only in the final message.

Authentication

The WebSocket API uses the same authentication model as the REST API:

  • Public projects — No API key required. Domain restrictions still apply.
  • Private projects — Include apiKey in the first message payload with chat_create permission.

Domain validation is checked on every message using the url field. If your project has allowed domains configured, the url must match one of them.

Rate limiting

LimitThresholdPenalty
Per chat session15 messages/minuteRejected until window resets
Per IP address100 messages/minuteIP blocked for 1 hour
Burst detection10 messages in 3 secondsRejected for 1 minute