Skip to main content

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:

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.
string
required
The user’s message or question
string
Unique identifier for conversation continuity. Auto-generated if not provided.
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
number
default:"0.7"
Response creativity (0.0 to 2.0)
number
default:"2048"
Maximum response length (1 to 4096)
array
Specific knowledge sources to queryOptions: wikipedia, academic_papers, news, documentation, all
object
Streaming configuration options
boolean
default:"true"
Include source citations in stream
boolean
default:"false"
Include processing metadata

Request Example

Streaming Response Format (SSE)

The response is streamed using Server-Sent Events (SSE) format:
string
Type of stream chunkValues: start, content, sources, metadata, end, error
string
Text content (for content type chunks)
array
Retrieved knowledge sources (for sources type chunks)
string
Source document title
string
Source URL or identifier
string
Relevant text excerpt
number
Relevance score (0.0 to 1.0)
object
Processing metadata (for metadata type chunks)
number
Total tokens consumed
number
Processing time in milliseconds
number
Number of sources searched

Example Stream Response


POST /chat/research

Trigger deep research mode for comprehensive, multi-source analysis.
string
required
Research question or topic
string
default:"standard"
Depth of research analysisOptions: quick, standard, deep, comprehensive
array
Types of sources to include in researchOptions: academic, wikipedia, news, documentation, books, patents
object
Filter sources by publication date
string
Start date (ISO 8601 format)
string
End date (ISO 8601 format)
number
default:"20"
Maximum number of sources to analyze (5 to 100)
string
default:"structured"
Response format structureOptions: structured, narrative, bullet_points, academic

Request Example

Response Format

string
Unique identifier for the research session
string
Original research query
string
Executive summary of findings
array
Main discoveries and insights
string
Key insight or discovery
number
Confidence score (0.0 to 1.0)
array
Sources supporting this finding
string
Comprehensive analysis text
array
All sources analyzed
string
Source title
array
Author names
string
Publication date
string
Source URL
number
Relevance to query (0.0 to 1.0)
array
Important points from source
object
Research session metadata
number
Total sources processed
number
Time taken in seconds
number
Overall confidence in findings

GET /chat/history

Retrieve conversation history for a specific conversation or user.
string
Specific conversation ID to retrieve
string
User ID to get all conversations for
number
default:"50"
Maximum number of messages to return (1 to 1000)
number
default:"0"
Number of messages to skip for pagination
string
Filter messages after this date (ISO 8601)
string
Filter messages before this date (ISO 8601)

Request Example

Response Format

string
Conversation identifier
array
Array of conversation messages
string
Unique message identifier
string
Message sender roleValues: user, assistant, system
string
Message content
string
Message timestamp (ISO 8601)
object
Additional message data
string
AI model that generated response
number
Tokens consumed for this message
array
Knowledge sources used
object
Pagination information
number
Total messages in conversation
boolean
Whether more messages are available
number
Offset for next page

DELETE /chat/history

Clear conversation history for a specific conversation or user.
string
Specific conversation to clear (optional if user_id provided)
string
Clear all conversations for user (optional if conversation_id provided)
string
Only clear messages before this date (ISO 8601)

Request Example

Response Format

boolean
Whether the operation was successful
number
Number of messages deleted
number
Number of conversations affected

WebSocket /ws/chat

Real-time bidirectional chat connection with live streaming and collaborative features.

Connection URL

Query Parameters

string
required
Your API authentication token
string
Conversation ID to connect to (auto-generated if not provided)
string
User identifier for multi-user conversations

Connection Example

Message Types

Client to Server Messages

string
required
Message typeValues: message, typing, stop_generation, join_room, leave_room
string
Message content (for message type)
string
AI model to use (for message type)
string
Room to join/leave (for room operations)

Server to Client Messages

string
Response typeValues: content, sources, user_message, typing, error, connection_info
string
Response content or user message
string
Username for user messages and typing indicators
string
Current conversation identifier
object
Error information (for error type)
string
Error code
string
Error description

Real-time Features

Typing Indicators

Multi-user Chat Rooms

Stop AI Generation


Error Handling

HTTP Error Codes

Bad Request
Invalid request parameters or malformed JSON
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions or quota exceeded
Not Found
Conversation or resource not found
Too Many Requests
Rate limit exceeded
Internal Server Error
Server error - try again later

Error Response Format

WebSocket Error Codes

Invalid Token
Authentication token is invalid or expired
Rate Limited
Too many messages sent too quickly
Invalid Message
Message format is invalid or unsupported
Conversation Not Found
Specified conversation ID doesn’t exist

Real Conversation Examples

Basic Q&A with Streaming

Deep Research Mode

WebSocket Multi-user Chat

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.