Generate an intelligent thread title using AI based on conversation content. Uses the last 10 messages for context and generates concise, descriptive titles. Supports streaming responses for real-time feedback.
You can optionally provide messages in the request body to avoid waiting for database saves (recommended for real-time UI updates).
thread_id string required
The unique identifier of the thread to generate a name for.
stream boolean optional · Defaults to false
Enable streaming mode to receive the generated name incrementally as it's created.
messages array optional
Array of message objects to use for name generation. If provided, these messages will be used instead of fetching from the database. This allows for instant name generation without waiting for database saves.
rolestring required - Message role (userorassistant)contentstring required - Message content
Behavior:
- If
messagesprovided: Uses messages from request body (no database lookup) - If
messagesnot provided: Fetches messages from database (existing behavior)
- Bash
- Python
- JavaScript
curl -X POST "https://api.freddy.aitronos.com/v1/threads/thread_abc123/generateName" \
-H "Authorization: Bearer $FREDDY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "How do I configure Docker volumes for my PostgreSQL database?"
},
{
"role": "assistant",
"content": "To configure Docker volumes for PostgreSQL, you can use named volumes..."
}
]
}'{
"success": true,
"threadId": "thread_abc123",
"name": "Customer Support Query",
"message": "Thread name generated successfully"
}The AI name generation uses the following logic:
- Context Analysis: Analyzes up to 10 messages from the thread (or provided messages)
- Title Generation: Creates concise, descriptive titles (2-5 words, maximum 50 characters)
- Focus on User Intent: Prioritizes user messages to understand what the user is asking about
- Intelligent Cleanup: Removes unnecessary prefixes, quotes, trailing punctuation
- Title Case Formatting: Ensures proper capitalization for readability
- Fallback Handling: Returns "Untitled" if generation fails
- Content Awareness: Considers conversation topics, user intent, and context
- Uses
ftg-3.0-speedfor fast, efficient title generation - No default system instructions to prevent bias
- Focused prompt explicitly emphasizing user messages and context
- Internal usage tracking (not visible in UI)
✅ Best for:
- Real-time UI updates (no database wait)
- Streaming responses (generate name immediately after response)
storeResponses=falsescenarios- Avoiding race conditions with message saving
// After streaming response completes
const nameResponse = await fetch(`/v1/threads/${threadId}/generateName`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
messages: [
{ role: 'user', content: userMessage },
{ role: 'assistant', content: assistantResponse }
]
})
});✅ Best for:
- Background name generation
- Threads with existing saved messages
- Regenerating names for old threads
// For existing threads with saved messages
await fetch(`/v1/threads/${threadId}/generateName`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${apiKey}` }
});| Feature | With Messages Parameter | From Database |
|---|---|---|
| Latency | Instant (no DB lookup) | Requires DB read |
| Race Conditions | None | Possible if messages not saved yet |
Works with storeResponses=false | ✅ Yes | ❌ No |
| Real-time UI | ✅ Recommended | ⚠️ Requires delay |
| Backward Compatible | ✅ Yes | ✅ Yes |