Chat API Endpoints
DeepWikiOpen provides powerful chat capabilities with streaming responses, deep research mode, conversation management, and real-time WebSocket connections.
Authentication
All chat endpoints require authentication using Bearer tokens:
Authorization: Bearer <your-api-key>
Rate Limits
- Standard Chat: 100 requests per minute
- Research Mode: 20 requests per minute
- WebSocket: 1000 messages per minute
- History Operations: 200 requests per minute
POST /chat/stream
Stream chat responses with RAG (Retrieval-Augmented Generation) capabilities.
The user’s message or question
Unique identifier for conversation continuity. Auto-generated if not provided.
model
string
default:"gpt-4-turbo"
AI model to use for response generationOptions: gpt-4-turbo
, gpt-3.5-turbo
, claude-3-opus
, claude-3-sonnet
Response creativity (0.0 to 2.0)
Maximum response length (1 to 4096)
Specific knowledge sources to queryOptions: wikipedia
, academic_papers
, news
, documentation
, all
Streaming configuration optionsInclude source citations in stream
Include processing metadata
Request Example
curl -X POST "https://api.deepwikiopen.com/chat/stream" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"message": "Explain quantum computing and its applications",
"conversation_id": "conv_123",
"model": "gpt-4-turbo",
"temperature": 0.7,
"context_sources": ["wikipedia", "academic_papers"],
"stream_options": {
"include_sources": true,
"include_metadata": true
}
}'
The response is streamed using Server-Sent Events (SSE) format:
Type of stream chunkValues: start
, content
, sources
, metadata
, end
, error
Text content (for content
type chunks)
Retrieved knowledge sources (for sources
type chunks)Relevance score (0.0 to 1.0)
Processing metadata (for metadata
type chunks)Processing time in milliseconds
Number of sources searched
Example Stream Response
data: {"type": "start", "conversation_id": "conv_123", "timestamp": "2024-01-15T10:30:00Z"}
data: {"type": "content", "content": "Quantum computing is a revolutionary"}
data: {"type": "content", "content": " approach to computation that leverages"}
data: {"type": "sources", "sources": [
{
"title": "Quantum Computing - Wikipedia",
"url": "https://en.wikipedia.org/wiki/Quantum_computing",
"snippet": "Quantum computing is a type of computation whose operations can harness the phenomena of quantum mechanics...",
"relevance_score": 0.92
}
]}
data: {"type": "content", "content": " quantum mechanical phenomena..."}
data: {"type": "metadata", "metadata": {"tokens_used": 156, "processing_time": 1250, "sources_queried": 5}}
data: {"type": "end", "conversation_id": "conv_123", "total_tokens": 156}
POST /chat/research
Trigger deep research mode for comprehensive, multi-source analysis.
Research question or topic
Depth of research analysisOptions: quick
, standard
, deep
, comprehensive
Types of sources to include in researchOptions: academic
, wikipedia
, news
, documentation
, books
, patents
Filter sources by publication dateStart date (ISO 8601 format)
End date (ISO 8601 format)
Maximum number of sources to analyze (5 to 100)
output_format
string
default:"structured"
Response format structureOptions: structured
, narrative
, bullet_points
, academic
Request Example
curl -X POST "https://api.deepwikiopen.com/chat/research" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"query": "Latest developments in CRISPR gene editing 2024",
"research_depth": "deep",
"source_types": ["academic", "news", "patents"],
"time_range": {
"start_date": "2024-01-01",
"end_date": "2024-12-31"
},
"max_sources": 50,
"output_format": "structured"
}'
Unique identifier for the research session
Executive summary of findings
Main discoveries and insightsConfidence score (0.0 to 1.0)
Sources supporting this finding
Comprehensive analysis text
All sources analyzedRelevance to query (0.0 to 1.0)
Important points from source
Research session metadataOverall confidence in findings
GET /chat/history
Retrieve conversation history for a specific conversation or user.
Specific conversation ID to retrieve
User ID to get all conversations for
Maximum number of messages to return (1 to 1000)
Number of messages to skip for pagination
Filter messages after this date (ISO 8601)
Filter messages before this date (ISO 8601)
Request Example
curl -X GET "https://api.deepwikiopen.com/chat/history?conversation_id=conv_123&limit=100" \
-H "Authorization: Bearer your-api-key"
Array of conversation messagesUnique message identifier
Message sender roleValues: user
, assistant
, system
Message timestamp (ISO 8601)
Additional message dataAI model that generated response
Tokens consumed for this message
Pagination informationTotal messages in conversation
Whether more messages are available
DELETE /chat/history
Clear conversation history for a specific conversation or user.
Specific conversation to clear (optional if user_id provided)
Clear all conversations for user (optional if conversation_id provided)
Only clear messages before this date (ISO 8601)
Request Example
curl -X DELETE "https://api.deepwikiopen.com/chat/history" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"conversation_id": "conv_123"
}'
Whether the operation was successful
Number of messages deleted
Number of conversations affected
WebSocket /ws/chat
Real-time bidirectional chat connection with live streaming and collaborative features.
Connection URL
wss://api.deepwikiopen.com/ws/chat?token=your-api-key&conversation_id=conv_123
Query Parameters
Your API authentication token
Conversation ID to connect to (auto-generated if not provided)
User identifier for multi-user conversations
Connection Example
const ws = new WebSocket('wss://api.deepwikiopen.com/ws/chat?token=your-api-key&conversation_id=conv_123');
ws.onopen = function(event) {
console.log('Connected to chat WebSocket');
// Send initial message
ws.send(JSON.stringify({
type: 'message',
content: 'Hello, can you help me with quantum computing?',
model: 'gpt-4-turbo'
}));
};
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
console.log('Received:', data);
switch(data.type) {
case 'content':
// Stream AI response content
process.stdout.write(data.content);
break;
case 'user_message':
// Another user's message in group chat
console.log(`${data.user}: ${data.content}`);
break;
case 'typing':
// Typing indicator
console.log(`${data.user} is typing...`);
break;
}
};
ws.onerror = function(error) {
console.error('WebSocket error:', error);
};
ws.onclose = function(event) {
console.log('Disconnected from chat WebSocket');
};
Message Types
Client to Server Messages
Message typeValues: message
, typing
, stop_generation
, join_room
, leave_room
Message content (for message
type)
AI model to use (for message
type)
Room to join/leave (for room operations)
Server to Client Messages
Response typeValues: content
, sources
, user_message
, typing
, error
, connection_info
Response content or user message
Username for user messages and typing indicators
Current conversation identifier
Error information (for error
type)
Real-time Features
Typing Indicators
// Send typing indicator
ws.send(JSON.stringify({
type: 'typing',
is_typing: true
}));
// Stop typing indicator
ws.send(JSON.stringify({
type: 'typing',
is_typing: false
}));
Multi-user Chat Rooms
// Join a chat room
ws.send(JSON.stringify({
type: 'join_room',
room_id: 'quantum_physics_discussion'
}));
// Leave a chat room
ws.send(JSON.stringify({
type: 'leave_room',
room_id: 'quantum_physics_discussion'
}));
Stop AI Generation
// Stop the AI from generating more content
ws.send(JSON.stringify({
type: 'stop_generation'
}));
Error Handling
HTTP Error Codes
Invalid request parameters or malformed JSON
Missing or invalid API key
Insufficient permissions or quota exceeded
Conversation or resource not found
Server error - try again later
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Try again in 60 seconds.",
"details": {
"retry_after": 60,
"current_usage": 100,
"limit": 100
}
}
}
WebSocket Error Codes
Authentication token is invalid or expired
Too many messages sent too quickly
Message format is invalid or unsupported
Specified conversation ID doesn’t exist
Real Conversation Examples
Basic Q&A with Streaming
# Request
curl -X POST "https://api.deepwikiopen.com/chat/stream" \
-H "Authorization: Bearer demo-key" \
-H "Content-Type: application/json" \
-d '{
"message": "What causes climate change?",
"context_sources": ["wikipedia", "academic_papers"]
}'
# Streaming Response
data: {"type": "start", "conversation_id": "conv_abc123"}
data: {"type": "content", "content": "Climate change is primarily caused by human activities that increase"}
data: {"type": "content", "content": " greenhouse gas concentrations in the atmosphere. The main causes include:"}
data: {"type": "sources", "sources": [
{
"title": "Climate Change - IPCC Report 2023",
"url": "https://www.ipcc.ch/report/ar6/",
"snippet": "Human influence has unequivocally warmed the planet...",
"relevance_score": 0.95
}
]}
data: {"type": "content", "content": "\n\n**1. Fossil Fuel Combustion**\nBurning coal, oil, and natural gas..."}
data: {"type": "end", "conversation_id": "conv_abc123", "total_tokens": 342}
Deep Research Mode
# Research Request
curl -X POST "https://api.deepwikiopen.com/chat/research" \
-H "Authorization: Bearer demo-key" \
-H "Content-Type: application/json" \
-d '{
"query": "Impact of AI on healthcare diagnostics",
"research_depth": "comprehensive",
"source_types": ["academic", "news", "documentation"],
"max_sources": 25
}'
# Response (truncated for brevity)
{
"research_id": "research_xyz789",
"query": "Impact of AI on healthcare diagnostics",
"summary": "AI is revolutionizing healthcare diagnostics through machine learning algorithms that can analyze medical images, predict disease outcomes, and assist in early detection with unprecedented accuracy...",
"key_findings": [
{
"finding": "AI diagnostic systems show 94% accuracy in detecting skin cancer vs 86% for dermatologists",
"confidence": 0.92,
"supporting_sources": ["Nature Medicine 2024", "JAMA Dermatology 2024"]
}
],
"sources": [
{
"title": "AI in Medical Diagnosis: A Systematic Review",
"authors": ["Smith, J.", "Chen, L.", "Kumar, R."],
"publication_date": "2024-03-15",
"url": "https://doi.org/10.1038/s41591-024-2847-2",
"relevance_score": 0.96,
"key_points": [
"Machine learning models outperform traditional diagnostic methods",
"Reduced diagnostic errors by 23% in clinical trials"
]
}
]
}
WebSocket Multi-user Chat
// User A connects and sends message
const wsA = new WebSocket('wss://api.deepwikiopen.com/ws/chat?token=user-a-key&room_id=ai_discussion');
wsA.send(JSON.stringify({
type: 'message',
content: 'What are the latest developments in transformer models?'
}));
// User B receives the message and AI response
// Message from User A: {"type": "user_message", "user": "UserA", "content": "What are..."}
// AI starts responding: {"type": "content", "content": "The latest developments..."}
// User B sends a follow-up
const wsB = new WebSocket('wss://api.deepwikiopen.com/ws/chat?token=user-b-key&room_id=ai_discussion');
wsB.send(JSON.stringify({
type: 'message',
content: 'Can you elaborate on attention mechanisms?'
}));
SDK Libraries
For easier integration, use our official SDK libraries:
- Python:
pip install deepwikiopen
- JavaScript/Node.js:
npm install deepwikiopen-sdk
- Go:
go get github.com/deepwikiopen/go-sdk
- Rust:
cargo add deepwikiopen
Each SDK provides typed interfaces, automatic retry logic, streaming support, and WebSocket management.