Skip to content
Last updated

🔨 In Development — This section is still being developed and may change.
Generate an intelligent thread title using AI based on conversation content. Supports streaming responses.
POSThttps://api.freddy.aitronos.com/v1/threads/{thread_id}/generateName

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).

Path Parameters

thread_id string required

The unique identifier of the thread to generate a name for.

Query Parameters

stream boolean optional · Defaults to false

Enable streaming mode to receive the generated name incrementally as it's created.

Request Body (Optional)

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.

  • role string required - Message role (user or assistant)
  • content string required - Message content

Behavior:

  • If messages provided: Uses messages from request body (no database lookup)
  • If messages not provided: Fetches messages from database (existing behavior)
Bash
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..."
      }
    ]
  }'

Response

{
  "success": true,
  "threadId": "thread_abc123",
  "name": "Customer Support Query",
  "message": "Thread name generated successfully"
}

AI Naming Logic

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

Name Generation Model

  • Uses ftg-3.0-speed for 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)

Use Cases

Best for:

  • Real-time UI updates (no database wait)
  • Streaming responses (generate name immediately after response)
  • storeResponses=false scenarios
  • 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 }
    ]
  })
});

Alternative: Fetch from Database

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}` }
});

Benefits

FeatureWith Messages ParameterFrom Database
LatencyInstant (no DB lookup)Requires DB read
Race ConditionsNonePossible if messages not saved yet
Works with storeResponses=false✅ Yes❌ No
Real-time UI✅ Recommended⚠️ Requires delay
Backward Compatible✅ Yes✅ Yes