WebSocket API
The Chucky service uses WebSocket for real-time bidirectional communication. This document describes the low-level protocol for developers who want to build custom clients.Most users should use the JavaScript SDK or Python SDK instead of the raw WebSocket API.
Connection
Endpoint
Authentication
Include your JWT token as a query parameter:Message Format
All messages are JSON-encoded with an envelope structure:Example
Connection Lifecycle
1
Connect
Client opens WebSocket connection to
wss://conjure.chucky.cloud/ws?token=<JWT>2
Initialize
Client sends
init message with session configuration3
Ready
Server responds with
control:ready when session is initialized4
Communicate
Client sends
sdk_message, server streams response chunks back5
Result
Server sends
result message when response is complete6
Close
Client sends
control:close to end session gracefullyInitialization
After connecting, send aninit message to configure the session:
Init Payload Options
| Field | Type | Description |
|---|---|---|
model | string | Claude model to use |
systemPrompt | string | System prompt |
maxTurns | number | Maximum conversation turns |
tools | array | Tool definitions |
mcpServers | array | MCP server definitions |
allowedTools | string[] | Whitelist of tools |
disallowedTools | string[] | Blacklist of tools |
Keep-Alive
Send periodic ping messages to keep the connection alive:Closing
To gracefully close a session:Error Handling
Errors are sent as:Error Codes
| Code | Description |
|---|---|
AUTHENTICATION_ERROR | Invalid or expired token |
BUDGET_EXCEEDED | AI or compute budget exceeded |
CONCURRENCY_LIMIT | Too many concurrent sessions |
RATE_LIMIT | Rate limit exceeded |
SESSION_ERROR | Session operation failed |
VALIDATION_ERROR | Invalid message format |