Skip to main content

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:
The token must be a valid JWT signed with your project’s HMAC secret. See Authentication for token creation.

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 configuration
3

Ready

Server responds with control:ready when session is initialized
4

Communicate

Client sends sdk_message, server streams response chunks back
5

Result

Server sends result message when response is complete
6

Close

Client sends control:close to end session gracefully

Initialization

After connecting, send an init message to configure the session:

Init Payload Options

Keep-Alive

Send periodic ping messages to keep the connection alive:
Server responds with:
Recommended interval: 30-60 seconds.

Closing

To gracefully close a session:

Error Handling

Errors are sent as:

Error Codes

Example: Minimal Client