Send Message
Send a message to an AI assistant in a chat session.The unique identifier of the session
The message text to send to the AI
Optional array of file paths to include as context
Optional array of image file paths to include
Response
Unique identifier for the sent message
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.The unique identifier of the session
Maximum number of messages to return (default: 100)
Number of messages to skip (for pagination)
Response
Array of message objects
Example Request
cURL
Stop Generation
Stop the AI from generating a response mid-stream.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.The unique identifier of the session
Execution mode for approved plan:
build or yoloExample Request
cURL
Answer Question
When the AI asks a question (waiting state), provide an answer.The unique identifier of the session
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:| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid message format or parameters |
| 401 | Unauthorized - Missing or invalid token |
| 404 | Not Found - Session does not exist |
| 429 | Rate Limit Exceeded - Too many requests |
| 500 | Internal Server Error - Server-side error |
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