Skip to main content
The WebSocket endpoint enables real-time, streaming communication with a Puppeteer agent. It supports sending messages and receiving streamed AI responses token by token.

Connection

Query parameters

Example

Sending messages

Send a JSON message to the WebSocket to interact with the agent:

Receiving messages

The server sends JSON messages over the WebSocket. Each message has a type field indicating what it is.

Stream start

Signals the beginning of a new AI message.

Tool running

Sent when a pre-response tool is being executed. The message can be displayed as a loading indicator.

Stream chunk

A token (word or partial word) of the AI’s response, delivered as it’s generated.

Stream end

Signals the end of an AI message and includes the complete response.
An agent may send multiple messages in a single response. Each message follows the full start → chunks → end sequence. An end_response event (see below) signals that all messages for the response are complete.

End response

Sent after all messages for a response are complete. Includes response-level metadata.

Error

Sent if an error occurs during processing.

Ping / Pong

Send a ping to check if the connection is still alive. The server responds with a pong. Client sends:
Server responds:

Example interaction

Client sends:
Server responds with a streamed reply: