Recommended Approach: Conversation threads are the preferred way to build multi-turn conversations with the Cura’s AI Model. They handle context automatically and provide a seamless experience.
Overview
Conversation threads enable stateful, context-aware conversations with the Cura AI without requiring you to manually manage message history. The server automatically:- Stores all messages in the conversation
- Injects the last 20 messages as context on every request
- Auto-deletes inactive threads after 30 minutes
- Isolates conversations for privacy and clarity
- Links threads to patient profiles (optional)
- Note: All cURL requests are case sensetive.
How It Works
1
Create a Thread
Make a Response:
POST /api/cura/threads request to get a unique 5-digit thread ID.2
Send Messages
Include the The server automatically:
threadId in your chat requests. The AI automatically receives the conversation history.- Loads the last 20 messages from this thread
- Sends them to the AI as context
- Appends the new message and response to the thread
- Updates the expiration time
3
Continue the Conversation
Just keep using the same The AI will remember everything from the thread automatically.
threadId. No need to send conversationHistory manually!4
End the Thread (Optional)
Threads auto-delete after 30 minutes of inactivity, or you can manually delete them:
Key Features
5-Digit Thread IDs
Each thread gets a unique 5-digit identifier (e.g.,82451, 19234) that you use to reference the conversation.
Automatic Context Injection
The server automatically loads and sends the last 20 messages from your thread to the AI on every request. You don’t need to:- Store messages on your end
- Send
conversationHistoryarrays - Manage context windows
30-Minute Auto-Expiration
Threads automatically delete themselves after 30 minutes of inactivity to:- Protect patient privacy
- Manage server resources
- Encourage focused conversations
Patient Linking (Optional)
Link a thread to a patient profile by providing theirpatientId or phone when creating the thread:
Thread Independence
Each thread is completely isolated. You can have multiple concurrent threads for different:- Patients
- Topics (e.g., one for medications, one for symptoms)
- Sessions
When to Use Threads
Use Threads When
- Building multi-turn conversations
- Creating chatbot interfaces
- Handling patient consultations
- Needing automatic context management
- Managing multiple conversations simultaneously
Don't Use Threads When
- Sending single, one-off questions
- Building stateless APIs
- You want full control over context
- Testing or debugging individual requests
Thread vs. Manual Context
- With Threads (Recommended)
- Without Threads (Manual)
Code Examples
Creating a Thread
Using a Thread in Conversation
Best Practices
Create threads at the start of a conversation session
Create threads at the start of a conversation session
When a user opens your app or starts a new chat, create a thread immediately. This ensures context is preserved throughout their session.
Display expiration times to users
Display expiration times to users
Show users when their thread will expire so they know how long they have for the conversation.
Link threads to patients when possible
Link threads to patients when possible
If you have patient information, link the thread to provide better context to the AI.
Clean up threads when users log out
Clean up threads when users log out
Manually delete threads when a user logs out or closes the app for privacy.
Store threadId on your side for analytics
Store threadId on your side for analytics
Keep track of thread IDs in your database to analyze conversation patterns and usage.
Related Endpoints
Create Thread
POST /api/cura/threadsGet Thread Info
GET /api/cura/threads/{id}Delete Thread
DELETE /api/cura/threads/{id}Chat with Thread
POST /api/cura/chat
