Sessions API
Manage chat sessions to maintain conversation context across multiple requests.
GET
/v1/sessionsReturns a list of all chat sessions for the authenticated user.
Query Parameters
limitoptionalNumber of sessions to return. Default: 20, Max: 100
offsetoptionalNumber of sessions to skip for pagination. Default: 0
Response
JSON
{
"object": "list",
"data": [
{
"id": "sess_abc123",
"title": "Quantum Computing Discussion",
"mode": "ensemble",
"message_count": 8,
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T11:45:00Z"
},
{
"id": "sess_def456",
"title": "Python Best Practices",
"mode": "smart_chat",
"message_count": 4,
"created_at": "2025-01-14T09:00:00Z",
"updated_at": "2025-01-14T09:30:00Z"
}
],
"has_more": true,
"total": 47
}GET
/v1/sessions/:idRetrieves a specific session including all messages.
Path Parameters
idrequiredThe unique identifier of the session.
Response
JSON
{
"id": "sess_abc123",
"title": "Quantum Computing Discussion",
"mode": "ensemble",
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T11:45:00Z",
"messages": [
{
"id": "msg_001",
"role": "user",
"content": "What is quantum computing?",
"created_at": "2025-01-15T10:30:00Z"
},
{
"id": "msg_002",
"role": "assistant",
"content": "Quantum computing is a type of computation...",
"models_used": ["gpt-4o", "claude-3-opus"],
"created_at": "2025-01-15T10:30:15Z"
}
]
}PATCH
/v1/sessions/:idUpdates a session's metadata (e.g., title).
Request Body
JSON
{
"title": "Updated Session Title"
}Response
JSON
{
"id": "sess_abc123",
"title": "Updated Session Title",
"mode": "ensemble",
"message_count": 8,
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-15T12:00:00Z"
}DELETE
/v1/sessions/:idPermanently deletes a session and all its messages.
Response
JSON
{
"id": "sess_abc123",
"object": "session.deleted",
"deleted": true
}Using Sessions in Chat
To continue a conversation, include the session_id in your chat request:
cURL
curl https://api.konnect.ai/v1/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Can you elaborate on that?",
"session_id": "sess_abc123"
}'The API will automatically include previous messages from the session as context.