Skip to content

Get Thread Messages

GET
/api/chat/threads/{thread_id}/messages

Get messages from a specific thread with pagination

Retrieves messages from a specific conversation thread with pagination support for lazy loading. Returns most recent messages first (when offset=0).

Args: request: FastAPI request object thread_id: Thread identifier to get messages from backend: Backend service instance (injected via dependency) limit: Maximum number of messages to return (default: 100) offset: Number of messages to skip (default: 0, for lazy loading older messages)

Returns: ThreadMessagesResponse: Messages with thread metadata and pagination info

thread_id
required
Thread Id
string
limit
Limit
integer
default: 100 >= 1 <= 1000
offset
Offset
integer
0

Successful Response

ThreadMessagesResponse

Thread messages retrieval response model - ULTRA-COMPLETE (45+ fields).

Provides all messages within a conversation thread for display and history browsing. Messages are ordered chronologically.

Fields: status: Response status (“success”, “error”) thread_id: Thread identifier messages: Ordered list of messages in thread count: Total number of messages in thread

Used By: - GET /api/chat/threads/{thread_id}/messages endpoint - Thread message history display - Conversation replay and review - Message export functionality

object
status
required
Status

Response status (‘success’ or ‘error’)

string
threadId
required
Threadid

Thread identifier

string
messages
required
Messages

Ordered list of messages in thread

Array<object>
ChatMessage

Individual chat message data model - ULTRA-COMPLETE (55+ fields).

Represents a single message within a conversation thread including role (user/assistant), content, and metadata. Used for message display and history reconstruction.

Fields: message_id: Unique message identifier thread_id: Parent thread identifier role: Message role (‘user’ or ‘assistant’) content: Message text content timestamp: Message creation timestamp (auto-generated) agent_used: Divine agent that generated response (for assistant messages) model_used: AI model used for generation (for assistant messages)

Used By: - ThreadMessagesResponse for message listings - Chat message display UI - Conversation history reconstruction - Message export and backup

object
messageId
required
Messageid

Unique message identifier

string
threadId
required
Threadid

Parent thread identifier

string
role
required
Role

Message role (‘user’ or ‘assistant’)

string
content
required
Content

Message text content

string
timestamp
Timestamp

Message timestamp

string format: date-time
agentUsed
Any of:
string
modelUsed
Any of:
string
isError
Any of:
boolean
senderName
Any of:
string
contentType
Any of:
string
workflowType
Any of:
string
sources
Any of:
Array<string>
uuid
Any of:
string
conversationId
Any of:
string
version
Any of:
string
schemaVersion
Any of:
string
userId
Any of:
string
sessionId
Any of:
string
projectId
Any of:
string
createdBy
Any of:
string
modifiedBy
Any of:
string
createdAt
Any of:
string
modifiedAt
Any of:
string
editedAt
Any of:
string
status
Any of:
string
isEdited
Any of:
boolean
isDeleted
Any of:
boolean
isPinned
Any of:
boolean
isFavorite
Any of:
boolean
responseTimeMs
Any of:
number
generationTimeMs
Any of:
number
tokensPerSecond
Any of:
number
tokensUsed
Any of:
integer
promptTokens
Any of:
integer
completionTokens
Any of:
integer
contextSources
Any of:
Array<object>
ContextSourceInfo

RAG context source information for chat responses.

Represents a single document or source used to provide context for AI responses through Retrieval-Augmented Generation (RAG). Includes relevance scoring and source metadata for attribution and transparency.

Fields: source: Document or source identifier score: Semantic similarity score (0.0-1.0, higher is more relevant) title: Human-readable source title content_preview: Preview snippet of relevant content document_type: Type of document (e.g., ‘lore’, ‘character’, ‘world’) collection: ChromaDB collection name

Used By: - ChatResponse.context_sources - EnhancedChatResponse.context_sources - ChatMessage.context_sources - ChatMessageInfo.context_sources

object
source
required
Source

Document or source identifier

string
score
required
Score

Semantic similarity score (0.0-1.0)

number
<= 1
title
Any of:
string
contentPreview
Any of:
string
documentType
Any of:
string
collection
Any of:
string
chunkIndex
Any of:
integer
metadata
Any of:
object
key
additional properties
string
ragEnabled
Any of:
boolean
ragSourcesCount
Any of:
integer
contextQuality
Any of:
number
searchResultsCount
Any of:
integer
qualityScore
Any of:
number
<= 100
relevanceScore
Any of:
number
<= 1
confidenceScore
Any of:
number
<= 1
parentMessageId
Any of:
string
previousMessageId
Any of:
string
nextMessageId
Any of:
string
replyToMessageId
Any of:
string
tags
Any of:
Array<string>
customMetadata
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string
persona
Any of:
string
stance
Any of:
string
thinkingSteps
Any of:
Array<object>
ThinkingStepInfo

Pipeline thinking step captured from a workflow callback.

Mirrors enhanced_chat_handler.ThinkingStep but lives in the schema package so response models can reference it without a circular import. Shape is authoritative — the only writer is WorkflowCallbackHandler which builds dicts with exactly these fields.

Used By: - ChatMessage.thinking_steps (restored from SQLite on thread load)

object
stepNumber
required
Stepnumber

Step index

integer
>= 1
stepName
required
Stepname

Human-readable step name

string
stepDescription
required
Stepdescription

Human-readable description

string
inputData
required
Inputdata

Inputs at step start

object
key
additional properties
any
outputData
required
Outputdata

Outputs at step end

object
key
additional properties
any
durationMs
required
Durationms

Step duration in ms

integer
timestamp
required
Timestamp

ISO timestamp

string
reasoningTrace
Any of:
Array<object>
ReasoningStepInfo

Individual reasoning step in AI thinking trace.

Represents a single step in the AI’s reasoning process for transparency and debugging. Includes step type, content, timing, and confidence.

Fields: step_number: Sequential step number step_type: Type of reasoning (e.g., ‘analysis’, ‘synthesis’, ‘evaluation’) content: Reasoning content or thought confidence: Confidence level for this step (0.0-1.0) duration_ms: Time taken for this step

Used By: - EnhancedChatResponse.reasoning_trace - ChatMessage.reasoning_trace - EnhancedChatStreamChunk.reasoning_trace

object
stepNumber
required
Stepnumber

Sequential step number

integer
>= 1
stepType
Any of:
string
content
required
Content

Reasoning content or thought

string
confidence
Any of:
number
<= 1
durationMs
Any of:
number
toolUsed
Any of:
string
result
Any of:
string
modelReasoning
Any of:
string
toolCalls
Any of:
Array<object>
object
key
additional properties
any
toolCallId
Any of:
string
originalContent
Any of:
string
images
Any of:
Array<object>
ImageAttachment

Base64-encoded image attached to a chat message.

object
mediaType
required
Mediatype

MIME type (image/png, image/jpeg, image/gif, image/webp)

string
data
required
Data

Base64-encoded image data

string
requestId
Any of:
string
traceId
Any of:
string
correlationId
Any of:
string
error
Any of:
string
warnings
Any of:
Array<string>
extra
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string
count
required
Count

Total number of messages in thread

integer
message
Any of:
string
page
Any of:
integer
>= 1
pageSize
Any of:
integer
>= 1
totalPages
Any of:
integer
hasNext
Any of:
boolean
hasPrevious
Any of:
boolean
userMessageCount
Any of:
integer
assistantMessageCount
Any of:
integer
totalTokens
Any of:
integer
averageResponseTimeMs
Any of:
number
threadTitle
Any of:
string
projectId
Any of:
string
conversationId
Any of:
string
filterRole
Any of:
string
filterAgent
Any of:
string
searchQuery
Any of:
string
sortBy
Any of:
string
sortOrder
Any of:
string
queryDurationMs
Any of:
number
cacheHit
Any of:
boolean
cacheAgeSeconds
Any of:
number
requestId
Any of:
string
userId
Any of:
string
sessionId
Any of:
string
traceId
Any of:
string
correlationId
Any of:
string
apiVersion
Any of:
string
serverVersion
Any of:
string
clientVersion
Any of:
string
timestamp
Any of:
string
oldestMessageTimestamp
Any of:
string
newestMessageTimestamp
Any of:
string
errors
Any of:
Array<string>
warnings
Any of:
Array<string>
environment
Any of:
string
region
Any of:
string
customMetadata
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string
deprecationNotice
Any of:
string
migrationGuide
Any of:
string
extra
Any of:
CustomMetadataInfo

Custom metadata container for extensibility.

Provides a structured container for custom key-value metadata that doesn’t fit into predefined fields. Supports common metadata patterns.

Fields: tags: List of tags for categorization labels: Key-value labels annotations: Additional annotations source: Data source identifier version: Data version

Used By: - Various models’ custom_metadata fields

object
tags
Any of:
Array<string>
labels
Any of:
object
key
additional properties
string
annotations
Any of:
object
key
additional properties
string
source
Any of:
string
version
Any of:
string
extra
Any of:
object
key
additional properties
string

Validation Error

HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object