Skip to content

FluxbaseAI

Fluxbase AI client for listing chatbots and managing conversations

const ai = new FluxbaseAI(fetchClient, 'ws://localhost:8080')
// List available chatbots
const { data, error } = await ai.listChatbots()
// Create a chat connection
const chat = ai.createChat({
token: 'my-jwt-token',
onContent: (delta) => process.stdout.write(delta),
})
await chat.connect()
const convId = await chat.startChat('sql-assistant')
chat.sendMessage(convId, 'Show me recent orders')

new FluxbaseAI(fetch, wsBaseUrl): FluxbaseAI

ParameterType
fetch{ delete: (path) => Promise<void>; get: <T>(path) => Promise<T>; patch: <T>(path, body?) => Promise<T>; }
fetch.delete(path) => Promise<void>
fetch.get<T>(path) => Promise<T>
fetch.patch<T>(path, body?) => Promise<T>
wsBaseUrlstring

FluxbaseAI

createChat(options): FluxbaseAIChat

Create a new AI chat connection

ParameterTypeDescription
optionsOmit<AIChatOptions, "wsUrl" | "_lookupChatbot">Chat connection options

FluxbaseAIChat

FluxbaseAIChat instance


deleteConversation(id): Promise<{ error: Error | null; }>

Delete a conversation

ParameterTypeDescription
idstringConversation ID

Promise<{ error: Error | null; }>

Promise resolving to { error } (null on success)

const { error } = await ai.deleteConversation('conv-uuid-123')
if (!error) {
console.log('Conversation deleted')
}

getChatbot(id): Promise<{ data: AIChatbotSummary | null; error: Error | null; }>

Get details of a specific chatbot

ParameterTypeDescription
idstringChatbot ID

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

Promise resolving to { data, error } tuple with chatbot details


getConversation(id): Promise<{ data: AIUserConversationDetail | null; error: Error | null; }>

Get a single conversation with all messages

ParameterTypeDescription
idstringConversation ID

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

Promise resolving to { data, error } tuple with conversation detail

const { data, error } = await ai.getConversation('conv-uuid-123')
if (data) {
console.log(`Title: ${data.title}`)
console.log(`Messages: ${data.messages.length}`)
}

listChatbots(): Promise<{ data: AIChatbotSummary[] | null; error: Error | null; }>

List available chatbots (public, enabled)

Promise<{ data: AIChatbotSummary[] | null; error: Error | null; }>

Promise resolving to { data, error } tuple with array of chatbot summaries


listConversations(options?): Promise<{ data: ListConversationsResult | null; error: Error | null; }>

List the authenticated user’s conversations

ParameterTypeDescription
options?ListConversationsOptionsOptional filters and pagination

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

Promise resolving to { data, error } tuple with conversations

// List all conversations
const { data, error } = await ai.listConversations()
// Filter by chatbot
const { data, error } = await ai.listConversations({ chatbot: 'sql-assistant' })
// With pagination
const { data, error } = await ai.listConversations({ limit: 20, offset: 0 })

lookupChatbot(name): Promise<{ data: AIChatbotLookupResponse | null; error: Error | null; }>

Lookup a chatbot by name with smart namespace resolution

Resolution logic:

  1. If exactly one chatbot with this name exists -> returns it
  2. If multiple exist -> tries “default” namespace first
  3. If multiple exist and none in “default” -> returns ambiguous=true with namespaces list
ParameterTypeDescription
namestringChatbot name

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

Promise resolving to { data, error } tuple with lookup result

// Lookup chatbot by name
const { data, error } = await ai.lookupChatbot('sql-assistant')
if (data?.chatbot) {
console.log(`Found in namespace: ${data.chatbot.namespace}`)
} else if (data?.ambiguous) {
console.log(`Chatbot exists in: ${data.namespaces?.join(', ')}`)
}

updateConversation(id, updates): Promise<{ data: AIUserConversationDetail | null; error: Error | null; }>

Update a conversation (currently supports title update only)

ParameterTypeDescription
idstringConversation ID
updatesUpdateConversationOptionsFields to update

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

Promise resolving to { data, error } tuple with updated conversation

const { data, error } = await ai.updateConversation('conv-uuid-123', {
title: 'My custom conversation title'
})