Base path:
/api/knowledge-basesTypes
Type Definitions
Type Definitions
Knowledge Base Endpoints
Create a new knowledge base
Defaults Applied: What happens on creation:- Knowledge base record is created in the database
- A Qdrant vector collection is created:
kb_{knowledgeBaseId}- Vector dimension: 1536 (matching OpenAI text-embedding-3-small)
- Distance metric: Cosine
List knowledge bases
Status Codes:Get a single knowledge base by ID
Status Codes:Update a knowledge base
Note:embeddingModel and chunkConfig cannot be changed after creation because changing them would require re-embedding all existing documents.
Status Codes:
Delete a knowledge base and all its documents, vectors, a…
Cleanup order:- Delete Qdrant collection (
kb_{id}) - removes all vectors - Delete all S3 files via FileService
- Soft-delete all
knowledge_base_documentsrecords - Soft-delete
knowledge_basesrecord
Document Endpoints
Upload a document for processing
Constraints: Processing Pipeline (async, after 202 response):List documents in a knowledge base
Status Codes:Get a single document’s status and details
Status Codes:
Processing in progress:
Delete a document, its S3 file, and all its vectors
Cleanup order:- Delete vectors from Qdrant (filtered by
documentId) - Delete S3 file via FileService
- Soft-delete
knowledge_base_documentsrecord - Decrement
documentCounton the knowledge base (only if document status was'ready')
Linking a Knowledge Base to an Agent
To enable RAG for an agent, update the agent with aknowledgeBaseConfig:
RAG Retrieval Behavior
When an agent has aknowledgeBaseConfig, retrieval happens automatically:
In Playground (POST /agents/:id/test)
- User sends a message
- The message is embedded using the KB’s embedding model
- Top-K similar chunks are retrieved from Qdrant (filtered by
documentGroupsif set) - Chunks below
similarityThresholdare discarded - Remaining chunks are formatted and prepended to the user message
- The enriched message is sent to the LLM
In Voice Calls (CONNECT_AGENT node)
Same flow as playground, but runs on every conversation turn:- User speaks, speech is transcribed (STT)
- A context-aware search query is built (includes previous turn for pronoun resolution)
- Top-K chunks are retrieved from Qdrant
- Chunks are formatted and prepended to the transcript
- The enriched transcript is sent to the LLM
- LLM response is synthesized to speech (TTS)
Context Injection Format
The LLM sees the user message in this format:Graceful Degradation
RAG failures never break the agent. If retrieval fails (Qdrant down, embedding API error, network timeout), the agent responds without KB context - it may hallucinate, but the conversation continues.RAG Latency Budget
This adds ~5-8% to total voice turn latency (~1.3-2.5s).Defaults & Limits Reference
Document Status State Machine
processing status):
processingStep field. On failure, the step is preserved to show where the pipeline broke. The S3 file is always preserved on failure to allow manual retry.
Frontend Integration Notes
Document Upload Flow
- Show file picker (accept
.txt,.md,.pdf, max 10MB) - POST multipart/form-data to
POST .../documents - Receive
202 Acceptedwith document object (status: 'uploading') - Poll
GET .../documents/:docIdevery 2-3 seconds - Show progress based on
processingStep: parsing -> chunking -> embedding -> upserting - When
statusbecomes'ready', show success withchunkCount - When
statusbecomes'failed', showerrorMessage
Document Groups
Document groups allow agents to query only relevant subsets of a KB:- Set
documentGroupduring upload (default:'default') - Configure
documentGroupsarray in agent’sknowledgeBaseConfig - If
documentGroupsisnull/undefined, all documents in the KB are searched - Example: A KB has groups
['product-docs', 'faqs', 'internal-notes']. An agent configured withdocumentGroups: ['product-docs', 'faqs']will only search those two groups.