Overview
The Document Cognition Service provides AI-powered chat functionality and document analysis capabilities. It processes user queries with document context, supports multiple AI models, and enables intelligent conversations about documents. Key Features:- Stream-based AI chat responses
- Document attachment analysis
- Multi-model support (Claude, GPT)
- Tool-augmented AI interactions
- Real-time notification delivery
- RESTful HTTP API with streaming endpoints
- WebSocket support via connection gateway
- Asynchronous AI processing
- Integration with search, email, and notification services
Chat Management
Create Chat
Display name for the chat session
AI model to use. Options:
claude-4-5-sonnet, claude-4-5-opus, gpt-4Project to associate this chat with
Document attachments to include in chat context
Whether to save chat history
Unique identifier for the created chat
Chat display name
AI model configured for this chat
Chat creation time
Get Chat
Retrieve chat details and metadata.Unique chat identifier
Chat display name
AI model for this chat
Associated project ID
Documents attached to this chat
Total number of messages in chat
Update Chat
New chat name
Switch AI model
Move chat to different project
Delete Chat
Soft-delete a chat (can be reverted).AI Chat Streaming
Send Chat Message
Send a message and receive a streaming AI response. The response is delivered via the connection gateway WebSocket.The user message content
Chat ID. If not provided, a new chat is created automatically
AI model:
claude-4-5-sonnet, claude-4-5-opus, gpt-4-turboCustom system instructions appended to the base prompt
Documents to include in the conversation context
Tools available to AI:
all, search, email, noneStream identifier to subscribe to for receiving response chunks
Unique ID for the AI response message
The chat ID (may differ from request if a new chat was created)
Chat History
Get Chat History
Retrieve message history for a chat.Maximum number of messages to return
Cursor for pagination - get messages before this ID
Array of chat messages
Unique message identifier
Message role:
user or assistantMessage text content
When the message was created
Whether more messages are available
Models
List Available Models
Get list of supported AI models.Available AI models
Model identifier (e.g.,
claude-4-5-sonnet)Human-readable model name
Maximum context size in tokens
Document Attachments
Get Chats for Attachment
Find all chats that reference a specific document.Chats containing this attachment
Chat identifier
Chat name
Most recent message timestamp
Processing Patterns
Async AI Processing
The Document Cognition Service uses asynchronous streaming for AI responses:- Initiate: POST to
/stream/chat/messagereturnsstreamId - Subscribe: Connect to WebSocket with
streamId - Stream: Receive incremental response chunks
- Complete: Final
StreamEndevent signals completion - Persist: Messages saved to chat history
Tool Integration
AI responses can invoke tools for enhanced capabilities:- Search: Query document search service
- Email: Access email content and metadata
- Scribe: Document summarization
- Soup: Web content extraction
Error Handling
Error message for stream failures
Associated stream ID if available
ModelContextOverflow: Message exceeds model’s context windowInternalError: AI service failureUnauthorized: Invalid or missing authenticationForbidden: Insufficient permissions for chat access
Rate Limits
Chat endpoints are subject to user quota limits:- Message rate: Based on user plan
- Context size: Model-dependent (see
/models) - Concurrent streams: 5 per user
X-RateLimit-Remaining: Messages remaining in quotaX-RateLimit-Reset: Quota reset timestamp