FluxbaseAI
Fluxbase AI client for listing chatbots and managing conversations
Example
Section titled “Example”const ai = new FluxbaseAI(fetchClient, 'ws://localhost:8080')
// List available chatbotsconst { data, error } = await ai.listChatbots()
// Create a chat connectionconst 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')Constructors
Section titled “Constructors”new FluxbaseAI()
Section titled “new FluxbaseAI()”new FluxbaseAI(
fetch,wsBaseUrl):FluxbaseAI
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
fetch | object |
fetch.delete | (path) => Promise<void> |
fetch.get | <T>(path) => Promise<T> |
fetch.patch | <T>(path, body?) => Promise<T> |
wsBaseUrl | string |
Returns
Section titled “Returns”Methods
Section titled “Methods”createChat()
Section titled “createChat()”createChat(
options):FluxbaseAIChat
Create a new AI chat connection
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | Omit<AIChatOptions, "wsUrl"> | Chat connection options |
Returns
Section titled “Returns”FluxbaseAIChat instance
deleteConversation()
Section titled “deleteConversation()”deleteConversation(
id):Promise<object>
Delete a conversation
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Conversation ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { error } (null on success)
| Name | Type |
|---|---|
error | null | Error |
Example
Section titled “Example”const { error } = await ai.deleteConversation('conv-uuid-123')if (!error) { console.log('Conversation deleted')}getChatbot()
Section titled “getChatbot()”getChatbot(
id):Promise<object>
Get details of a specific chatbot
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Chatbot ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with chatbot details
| Name | Type |
|---|---|
data | null | AIChatbotSummary |
error | null | Error |
getConversation()
Section titled “getConversation()”getConversation(
id):Promise<object>
Get a single conversation with all messages
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Conversation ID |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with conversation detail
| Name | Type |
|---|---|
data | null | AIUserConversationDetail |
error | null | Error |
Example
Section titled “Example”const { data, error } = await ai.getConversation('conv-uuid-123')if (data) { console.log(`Title: ${data.title}`) console.log(`Messages: ${data.messages.length}`)}listChatbots()
Section titled “listChatbots()”listChatbots():
Promise<object>
List available chatbots (public, enabled)
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with array of chatbot summaries
| Name | Type |
|---|---|
data | null | AIChatbotSummary[] |
error | null | Error |
listConversations()
Section titled “listConversations()”listConversations(
options?):Promise<object>
List the authenticated user’s conversations
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | ListConversationsOptions | Optional filters and pagination |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with conversations
| Name | Type |
|---|---|
data | null | ListConversationsResult |
error | null | Error |
Example
Section titled “Example”// List all conversationsconst { data, error } = await ai.listConversations()
// Filter by chatbotconst { data, error } = await ai.listConversations({ chatbot: 'sql-assistant' })
// With paginationconst { data, error } = await ai.listConversations({ limit: 20, offset: 0 })updateConversation()
Section titled “updateConversation()”updateConversation(
id,updates):Promise<object>
Update a conversation (currently supports title update only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id | string | Conversation ID |
updates | UpdateConversationOptions | Fields to update |
Returns
Section titled “Returns”Promise<object>
Promise resolving to { data, error } tuple with updated conversation
| Name | Type |
|---|---|
data | null | AIUserConversationDetail |
error | null | Error |
Example
Section titled “Example”const { data, error } = await ai.updateConversation('conv-uuid-123', { title: 'My custom conversation title'})