Chat
Ask questions against your documents with AI-powered answers and source citations.
The chat endpoint is the core of the Knowbase API. Ask questions about your documents and get AI-powered answers with source citations.
Send a query (non-streaming)
POST https://api.knowbase.ai/api/v1/chat
Headers
Authorization*
string
Bearer YOUR_API_TOKEN
Content-Type*
string
application/json
Request Body
question
string
Yes
Your question
file_ids
array
No
List of file IDs to query. Omit to search entire library
collection_id
string
No
Collection ID to query (alternative to file_ids)
conversation_id
string
No
Continue a previous conversation for follow-up questions
thinking_mode
boolean
No
Enable advanced multi-step reasoning (Pro/Team only)
Example request
{
"question": "What were the key revenue drivers in Q4?",
"file_ids": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
"conversation_id": null,
"thinking_mode": false
}Response (200: OK)
The sources array contains numbered references matching the [1], [2] citations in the answer. The source field indicates the page number (for documents) or timestamp (for audio/video).
Send a query (streaming SSE)
POST https://api.knowbase.ai/api/v1/chat/stream
Same request body as /chat, but returns a Server-Sent Events stream for real-time token-by-token output.
SSE Events
sources
Source citations (sent first)
{"sources": [...], "documentType": "pdf"}
token
Incremental text token
{"t": "word "}
thinking
Thinking mode progress
{"step": "searching", ...}
done
Full response complete
{"full_text": "...", "conversation_id": "..."}
error
Error occurred
{"error": {"code": "...", "message": "..."}}
Example: Streaming in Python
Example: Streaming in JavaScript
Query scoping
You can control which documents are searched:
Entire library
Omit both file_ids and collection_id
Specific files
Set file_ids: ["id1", "id2"]
A collection
Set collection_id: "collection-uuid"
Thinking mode
Set thinking_mode: true for complex questions that benefit from multi-step reasoning. The AI will iteratively search, assess confidence, and refine its answer. Available on Pro and Team plans.
In streaming mode, you'll receive additional thinking events showing the AI's reasoning progress.
Per-user sessions
If you're integrating Knowbase into a product that serves multiple end users, pass a stable session_id for each user. Same session_id continues the same conversation; different session_ids under the same API account are fully isolated — no cross-user history leakage.
You don't need to track Knowbase's conversation_id on your side; just send your own user identifier as session_id and we'll resolve it to the right thread.
Example: two users under one API account
Notes
session_idis an opaque string of your choice (max 255 chars). We recommend using your product's stable user identifier.If you send both
conversation_idandsession_id,conversation_idwins (back-compat).To list a single user's conversations, see Listing conversations by session.
Quotas and rate limits are enforced per API account, not per session. For high-volume integrations, contact us about an Enterprise plan.
Last updated