Create Session
Endpoint:POST /api/rag-chat/sessions
Create a new chat session with specified knowledge bases.
Array of knowledge base IDs to query (must not be empty)
Optional custom title for the session
List Sessions
Endpoint:GET /api/rag-chat/sessions
Retrieve all chat sessions, ordered by last activity (pinned sessions first).
Response:
Get Session Details
Endpoint:GET /api/rag-chat/sessions/{sessionId}
Retrieve full session information including all messages.
Response:
Send Message (Streaming)
Endpoint:POST /api/rag-chat/sessions/{sessionId}/messages/stream
Content-Type: application/jsonResponse Type:
text/event-stream (Server-Sent Events)
Send a message and receive AI response as a stream.
The user’s question or message
Newlines are escaped as
\\n and carriage returns as \\r to preserve SSE protocol. Unescape when displaying.Update Session Title
Endpoint:PUT /api/rag-chat/sessions/{sessionId}/title
Change the session’s display title.
New title for the session
Toggle Pin Status
Endpoint:PUT /api/rag-chat/sessions/{sessionId}/pin
Toggle whether the session is pinned. Pinned sessions appear first in the session list.
Response:
Update Knowledge Bases
Endpoint:PUT /api/rag-chat/sessions/{sessionId}/knowledge-bases
Change which knowledge bases the session queries.
New array of knowledge base IDs (must not be empty)
Delete Session
Endpoint:DELETE /api/rag-chat/sessions/{sessionId}
Permanently delete the session and all associated messages.
Response:
Error Responses
| Code | Description | Example |
|---|---|---|
| 400 | Bad Request | {"code":400,"message":"knowledgeBaseIds cannot be empty"} |
| 404 | Not Found | {"code":404,"message":"Session not found: 999"} |
| 500 | Server Error | {"code":500,"message":"Failed to generate response"} |
