Skip to content

FluxbaseKnowledgeBase

FluxbaseKnowledgeBase provides knowledge base management for RAG applications

// List knowledge bases
const { data: kbs } = await client.knowledgeBase.list()
// Create a knowledge base
const { data: kb } = await client.knowledgeBase.create({
name: 'Product Docs',
description: 'Product documentation for RAG'
})
// Add a document
const { data } = await client.knowledgeBase.addDocument(kb.id, {
title: 'Getting Started',
content: 'Welcome to our product...'
})
// Search the knowledge base
const { data: results } = await client.knowledgeBase.search(kb.id, {
query: 'How to get started?'
})

new FluxbaseKnowledgeBase(fetch): FluxbaseKnowledgeBase

ParameterType
fetchFluxbaseFetch

FluxbaseKnowledgeBase

addDocument(kbId, request): Promise<FluxbaseResponse<AddDocumentResponse>>

Add a document with text content

ParameterTypeDescription
kbIdstringKnowledge base ID
requestAddDocumentRequestDocument content and metadata

Promise<FluxbaseResponse<AddDocumentResponse>>

const { data } = await client.knowledgeBase.addDocument(kbId, {
title: 'API Reference',
content: 'The API supports REST and GraphQL...',
metadata: { category: 'reference' },
tags: ['api', 'reference']
})

create(request): Promise<FluxbaseResponse<KnowledgeBase>>

Create a new knowledge base

ParameterTypeDescription
requestCreateKnowledgeBaseRequestKnowledge base configuration

Promise<FluxbaseResponse<KnowledgeBase>>

const { data, error } = await client.knowledgeBase.create({
name: 'Product Docs',
description: 'Product documentation',
embedding_model: 'text-embedding-3-small',
chunk_size: 1000,
chunk_overlap: 200
})

delete(id): Promise<{ data: boolean; error: Error | null; }>

Delete a knowledge base

ParameterTypeDescription
idstringKnowledge base ID

Promise<{ data: boolean; error: Error | null; }>


deleteDocument(kbId, docId): Promise<{ data: boolean; error: Error | null; }>

Delete a document

ParameterTypeDescription
kbIdstringKnowledge base ID
docIdstringDocument ID

Promise<{ data: boolean; error: Error | null; }>


deleteDocumentsByFilter(kbId, filter): Promise<FluxbaseResponse<DeleteDocumentsByFilterResponse>>

Delete documents matching a filter (bulk operation)

ParameterTypeDescription
kbIdstringKnowledge base ID
filterDeleteDocumentsByFilterRequestFilter criteria (by tags and/or metadata)

Promise<FluxbaseResponse<DeleteDocumentsByFilterResponse>>


get(id): Promise<FluxbaseResponse<KnowledgeBase>>

Get a knowledge base by ID

ParameterTypeDescription
idstringKnowledge base ID

Promise<FluxbaseResponse<KnowledgeBase>>


getDocument(kbId, docId): Promise<FluxbaseResponse<KnowledgeBaseDocument>>

Get a single document

ParameterTypeDescription
kbIdstringKnowledge base ID
docIdstringDocument ID

Promise<FluxbaseResponse<KnowledgeBaseDocument>>


getEntityRelationships(kbId, entityId): Promise<FluxbaseResponse<AIEntityRelationship[]>>

Get relationships for an entity

ParameterTypeDescription
kbIdstringKnowledge base ID
entityIdstringEntity ID

Promise<FluxbaseResponse<AIEntityRelationship[]>>


getKnowledgeGraph(kbId): Promise<FluxbaseResponse<KnowledgeGraphData>>

Get the full knowledge graph for a knowledge base

Returns all entities and relationships for visualization.

ParameterTypeDescription
kbIdstringKnowledge base ID

Promise<FluxbaseResponse<KnowledgeGraphData>>


list(): Promise<FluxbaseResponse<KnowledgeBaseSummary[]>>

List all knowledge bases the user has access to

Promise<FluxbaseResponse<KnowledgeBaseSummary[]>>

const { data, error } = await client.knowledgeBase.list()

listDocuments(kbId): Promise<FluxbaseResponse<KnowledgeBaseDocument[]>>

List documents in a knowledge base

ParameterTypeDescription
kbIdstringKnowledge base ID

Promise<FluxbaseResponse<KnowledgeBaseDocument[]>>


listEntities(kbId, type?): Promise<FluxbaseResponse<AIEntity[]>>

List entities in a knowledge base

ParameterTypeDescription
kbIdstringKnowledge base ID
type?AIEntityTypeOptional entity type filter

Promise<FluxbaseResponse<AIEntity[]>>


search(kbId, request): Promise<FluxbaseResponse<SearchKnowledgeBaseResponse>>

Search a knowledge base using semantic similarity

Automatically embeds the query text and returns matching chunks.

ParameterTypeDescription
kbIdstringKnowledge base ID
requestSearchKnowledgeBaseRequestSearch parameters

Promise<FluxbaseResponse<SearchKnowledgeBaseResponse>>

const { data, error } = await client.knowledgeBase.search(kbId, {
query: 'How to configure authentication?',
max_chunks: 5,
threshold: 0.8
})
data.results.forEach(result => {
console.log(result.document_title, result.similarity)
console.log(result.content)
})

searchEntities(kbId, query): Promise<FluxbaseResponse<AIEntity[]>>

Search entities by name

ParameterTypeDescription
kbIdstringKnowledge base ID
querystringSearch query

Promise<FluxbaseResponse<AIEntity[]>>


update(id, updates): Promise<FluxbaseResponse<KnowledgeBase>>

Update a knowledge base

ParameterTypeDescription
idstringKnowledge base ID
updatesUpdateKnowledgeBaseRequestFields to update

Promise<FluxbaseResponse<KnowledgeBase>>


updateDocument(kbId, docId, updates): Promise<FluxbaseResponse<KnowledgeBaseDocument>>

Update a document’s metadata

ParameterTypeDescription
kbIdstringKnowledge base ID
docIdstringDocument ID
updatesUpdateDocumentRequestFields to update

Promise<FluxbaseResponse<KnowledgeBaseDocument>>


uploadDocument(kbId, file, filename, metadata?): Promise<FluxbaseResponse<UploadDocumentResponse>>

Upload a file as a document

Supports: PDF, TXT, MD, HTML, CSV, DOCX, XLSX, RTF, EPUB, JSON (max 50MB)

ParameterTypeDescription
kbIdstringKnowledge base ID
fileArrayBuffer | Blob | FileFile to upload (File, Blob, or ArrayBuffer)
filenamestringName of the file
metadata?Record<string, string>Optional metadata

Promise<FluxbaseResponse<UploadDocumentResponse>>

const file = new File(['content'], 'guide.pdf', { type: 'application/pdf' })
const { data } = await client.knowledgeBase.uploadDocument(kbId, file, 'guide.pdf')