Interactive Chat
Real-time conversational financial assistant
What It Does
The Chat API provides a conversational interface for financial research. Ask questions, explore ideas, and get instant responses with real-time streaming. Perfect for interactive research sessions and exploratory analysis.
Real-time Streaming
Server-Sent Events deliver tokens as they're generated
Context Aware
Maintains conversation history for follow-up questions
Market Data
Access to real-time financial data during conversation
When to Use
Perfect For
- • Interactive research sessions
- • Client Q&A interfaces
- • Exploratory analysis
- • Trading desk assistants
- • Educational platforms
Not Ideal For
- • Batch processing
- • Structured reports
- • Automated workflows
- • Historical archives
- • Static analysis
Implementation
Basic Conversation
Request
POST /api/chat
{
"message": "What's driving NVDA's growth?",
"conversation_id": null
}
Response
{
"conversation_id": "abc-123",
"message_id": "msg-456",
"response": "NVIDIA's growth is driven by..."
}
Streaming Response
// JavaScript SSE implementation
const eventSource = new EventSource(
`/api/chat/stream?conversation_id=${conversationId}`,
{ headers: { "X-API-Key": apiKey } }
);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
switch(data.type) {
case 'token':
// Append text token to UI
appendText(data.content);
break;
case 'done':
// Complete message received
eventSource.close();
break;
}
};
Streaming Events
| Event Type | Description | Data |
|---|---|---|
| token | Text chunk | {"type": "token", "content": "..."} |
| node_start | Processing phase begins | {"type": "node_start", "node": "research"} |
| tool_start | Tool execution begins | {"type": "tool_start", "tool": "market_data"} |
| tool_end | Tool execution completes | {"type": "tool_end", "tool": "market_data"} |
| done | Stream complete | {"type": "done", "conversation_id": "..."} |
Conversation Management
Starting a Conversation
Set conversation_id: null to start a new conversation.
The response includes the new ID for follow-ups.
{
"message": "Analyze Tesla",
"conversation_id": null
}
Continuing a Conversation
Include the conversation_id from previous responses
to maintain context.
{
"message": "What about their margins?",
"conversation_id": "abc-123"
}
Pro Tips
Handle disconnects: Implement reconnection logic for SSE streams in production.
Context limits: Conversations maintain ~10 message pairs. Start new for unrelated topics.
Stream buffering: Buffer tokens client-side for smoother UI rendering.
Error recovery: Save conversation_id locally to resume after network issues.