Send Message
Send a message to an AI assistant in a chat session.string
required
The unique identifier of the session
string
required
The message text to send to the AI
array
Optional array of file paths to include as context
array
Optional array of image file paths to include
Response
string
Unique identifier for the sent message
string
Message status:
sent, processing, or completedExample Request
cURL
Example Response
Stream Messages (WebSocket)
For real-time chat interactions, use the WebSocket connection to stream messages and responses.Connect to WebSocket
Send Message via WebSocket
Receive Streaming Response
As the AI generates a response, you’ll receive multiple events:Message Started
Content Delta
Streaming chunks of the AI’s response:Tool Use
When the AI uses a tool (e.g., editing a file):Message Completed
Message Error
Get Message History
Retrieve all messages in a session.string
required
The unique identifier of the session
number
Maximum number of messages to return (default: 100)
number
Number of messages to skip (for pagination)
Response
array
Array of message objects
Example Request
cURL
Stop Generation
Stop the AI from generating a response mid-stream.string
required
The unique identifier of the session
Example Request
cURL
Approve Plan
When a session is in plan mode and has proposed changes, approve the plan to execute it.string
required
The unique identifier of the session
string
required
Execution mode for approved plan:
build or yoloExample Request
cURL
Answer Question
When the AI asks a question (waiting state), provide an answer.string
required
The unique identifier of the session
string
required
The answer to the AI’s question
Example Request
cURL
WebSocket Connection
The WebSocket connection provides bidirectional real-time communication.Authentication
Include your token as a query parameter:Dual Emission
Jean uses a dual emission pattern for WebSocket events:- Global broadcast: All events are sent to all connected clients
- Targeted emission: Events related to a specific session are also sent to clients that have subscribed to that session
- Listen to all activity across Jean (for dashboard views)
- Subscribe to specific sessions for focused updates
Subscribe to Session
Unsubscribe from Session
Error Responses
The Chat API returns standard HTTP error codes:Example Error Response
Best Practices
Use WebSocket for interactive chat
Use WebSocket for interactive chat
For real-time chat interactions, use the WebSocket connection to receive streaming responses and immediate updates. HTTP requests are better suited for batch operations or simple queries.
Handle reconnection
Handle reconnection
WebSocket connections can drop. Implement reconnection logic with exponential backoff to maintain a stable connection.
Store message history locally
Store message history locally
Cache message history on the client side to reduce API calls and improve response times. Use the WebSocket events to keep the cache synchronized.
Implement typing indicators
Implement typing indicators
Show typing indicators when receiving
content-delta events to provide feedback to users during streaming responses.Next Steps
Sessions API
Manage chat sessions within worktrees
Remote Access Guide
Learn more about Jean’s HTTP server and WebSocket API