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
fetchobject
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">Chat connection options

FluxbaseAIChat

FluxbaseAIChat instance


deleteConversation(id): Promise<object>

Delete a conversation

ParameterTypeDescription
idstringConversation ID

Promise<object>

Promise resolving to { error } (null on success)

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

getChatbot(id): Promise<object>

Get details of a specific chatbot

ParameterTypeDescription
idstringChatbot ID

Promise<object>

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

NameType
datanull | AIChatbotSummary
errornull | Error

getConversation(id): Promise<object>

Get a single conversation with all messages

ParameterTypeDescription
idstringConversation ID

Promise<object>

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

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

listChatbots(): Promise<object>

List available chatbots (public, enabled)

Promise<object>

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

NameType
datanull | AIChatbotSummary[]
errornull | Error

listConversations(options?): Promise<object>

List the authenticated user’s conversations

ParameterTypeDescription
options?ListConversationsOptionsOptional filters and pagination

Promise<object>

Promise resolving to { data, error } tuple with conversations

NameType
datanull | ListConversationsResult
errornull | Error
// 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 })

updateConversation(id, updates): Promise<object>

Update a conversation (currently supports title update only)

ParameterTypeDescription
idstringConversation ID
updatesUpdateConversationOptionsFields to update

Promise<object>

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

NameType
datanull | AIUserConversationDetail
errornull | Error
const { data, error } = await ai.updateConversation('conv-uuid-123', {
title: 'My custom conversation title'
})