Skip to content

boostgpt/boostgpt-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoostGPT Node.js Client

Official BoostGPT client library for Node.js with full ES Modules (ESM) and CommonJS (CJS) support.

NPM Version Discord Documentation

Features

  • Full ES Modules (ESM) and CommonJS (CJS) support
  • Complete API coverage for all BoostGPT endpoints
  • Bot/Agent management (create, read, update, delete)
  • Chat operations with streaming support
  • Memory source/training management
  • Tools management (MCP server integration)
  • Message voting and feedback
  • Subscriber management
  • Comprehensive analytics and statistics
  • TypeScript-friendly (type definitions coming soon)

Table of Contents

Requirements

  • Node.js >= 12.20.0
  • For ES Modules: Node.js >= 14.0.0 recommended
  • BoostGPT API Key

Installation

npm install boostgpt

Usage

ES Modules (Recommended)

import { BoostGPT } from 'boostgpt';

const client = new BoostGPT({
    project_id: 'your-project-id',
    key: 'your-api-key'
});

// Create a bot
const botResponse = await client.createBot({
    name: 'My Bot',
    model: 'gpt-4o-min',
    instruction: 'You are a helpful assistant',
    max_reply_tokens: 1000,
    status: 1
});

if (botResponse.err) {
    console.error('Error:', botResponse.err);
} else {
    console.log('Bot created:', botResponse.response);
}

// Chat with the bot
const chatResponse = await client.chat({
    bot_id: 'bot-id',
    message: 'Hello, how are you?'
});

console.log('Response:', chatResponse.response);

CommonJS (Legacy Support)

const { BoostGPT } = require('boostgpt');

const client = new BoostGPT({
    project_id: 'your-project-id',
    key: 'your-api-key'
});

// Use async/await or promises
(async () => {
    const botResponse = await client.createBot({
        name: 'My Bot',
        model: 'gpt-4o-min',
        instruction: 'You are a helpful assistant'
    });
    
    console.log(botResponse.response);
})();

API Reference

Constructor

const client = new BoostGPT({
    project_id: 'your-project-id',  // Required
    key: 'your-api-key'              // Required
});

Bot Management

Create Bot

await client.createBot({
    name: 'Bot Name',
    model: 'gpt-4o-min',
    instruction: 'System instruction',
    max_reply_tokens: 1000,
    status: 1
});

Fetch Bot

await client.fetchBot(bot_id);

Fetch All Bots

await client.fetchBots({
    page: 1,
    per_page: 10
});

Update Bot

await client.updateBot({
    bot_id: 'bot-id',
    name: 'Updated Name',
    model: 'gpt-5.1',
    instruction: 'Updated instruction',
    max_reply_tokens: 1500,
    status: "0" // 1 = online, 0 = offline
});

Reset Bot

await client.resetBot(bot_id);

Delete Bot

await client.deleteBot(bot_id);

Chat Operations

Send Chat Message

await client.chat({
    bot_id: 'bot-id',
    model: 'gpt-4o-min',  //Optional
    provider_key: 'optional-provider-key', //Optional
    provider_host: 'optionl-provider-host', // Only needed and required when using ollama models
    instruction: 'Optional override instruction',
    reasoning_mode: 'optional-reasoning-mode', //Default to standard
    source_ids: ['source1', 'source2'], //Optional
    message: 'Your message here',
    max_reply_tokens: 1000,  //Optional
    chat_id: 'optional-chat-id',
    stream: false,  //Optional
    memory: false // Optional: Disables the agents memory
});

Search

await client.search({
    bot_id: 'bot-id',
    source_ids: ['source1', 'source2'],
    keywords: 'search terms'
});

Fetch Chat

await client.fetchChat({
    bot_id: 'bot-id',
    chat_id: 'chat-id',
    page: 1,
    per_page: 10
});

Fetch All Chats

await client.fetchChats({
    bot_id: 'bot-id',
    page: 1,
    per_page: 10
});

Delete Chat

await client.deleteChat({
    chat_id: 'chat-id',
    bot_id: 'bot-id'
});

Execute Tool

await client.executeTool({
    bot_id: 'bot-id',
    chat_id: 'chat-id',
    tool_calls: [
        {
            tool_name: 'calculator',
            parameters: { operation: 'add', a: 5, b: 3 }
        }
    ]
});

Vote on Message

await client.voteMessage({
    bot_id: 'bot-id',
    message_id: 'message-id',
    voter_id: 'user-id',
    voter_type: 'member',
    vote_type: 'upvote' // or 'downvote'
});

Fetch Vote Status

await client.fetchVoteStatus({
    bot_id: 'bot-id',
    message_id: 'message-id',
    voter_id: 'user-id',
    voter_type: 'member'
});

Delete Message

await client.deleteMessage({
    bot_id: 'bot-id',
    chat_id: 'chat-id',
    message_id: 'message-id'
});

Training/Source Management

Start Training

await client.startTraining({
    bot_id: 'bot-id',
    type: 'text',
    source: 'Training content here'
});

Fetch Training

await client.fetchTraining({
    source_id: 'source-id',
    bot_id: 'bot-id'
});

Fetch All Trainings

await client.fetchTrainings({
    bot_id: 'bot-id',
    page: 1,
    per_page: 10
});

Update Training

await client.updateTraining({
    source_id: 'source-id',
    bot_id: 'bot-id',
    type: 'text',
    source: 'Updated content'
});

Delete Training

await client.deleteTraining({
    source_id: 'source-id',
    bot_id: 'bot-id'
});

Tools Management

Fetch Tools

await client.fetchTools({
    bot_id: 'bot-id',
    page: 1,
    per_page: 10,
    filter: { type: 'mcp' } // Optional filter
});

Create Tool

await client.createTool({
    bot_id: 'bot-id',
    name: 'My Tool',
    description: 'Tool description',
    config: {
        url: 'https://api.example.com',
        auth: 'bearer_token'
    },
    type: 'mcp'
});

Fetch Tool

await client.fetchTool({
    tool_id: 'tool-id',
    bot_id: 'bot-id'
});

Update Tool

await client.updateTool({
    tool_id: 'tool-id',
    bot_id: 'bot-id',
    name: 'Updated Tool Name',
    description: 'Updated description',
    config: { /* updated config */ },
    type: 'mcp'
});

Delete Tool

await client.deleteTool({
    tool_id: 'tool-id',
    bot_id: 'bot-id'
});

Configure Tools

await client.configureTools({
    tool_id: 'tool-id',
    bot_id: 'bot-id',
    settings: {
        enabled: true,
        timeout: 30000
    }
});

Refresh Tools

await client.refreshTools({
    tool_id: 'tool-id',
    bot_id: 'bot-id'
});

Toggle Tool

await client.toggleTool({
    tool_id: 'tool-id',
    bot_id: 'bot-id',
    tool_name: 'specific-tool',
    active: true
});

Test Tool Connection

await client.testToolConnection({
    tool_id: 'tool-id',
    bot_id: 'bot-id'
});

Subscribers

Fetch Subscribers

await client.fetchSubscribers({
    page: 1,
    per_page: 10
});

Analytics

Fetch Vote Statistics

await client.fetchVoteStats({
    bot_id: 'bot-id'
});

Fetch Summary Statistics

await client.fetchSummaryStats({
    bot_id: 'bot-id'
});

Fetch Dashboard Statistics

await client.fetchDashboardStats({
    bot_id: 'bot-id'
});

Fetch Tool Usage Statistics

await client.fetchToolUsageStats({
    bot_id: 'bot-id'
});

Fetch Workflow Statistics

await client.fetchWorkflowStats({
    bot_id: 'bot-id'
});

Fetch Performance Metrics

await client.fetchPerformanceMetrics({
    bot_id: 'bot-id'
});

Fetch User Behavior Statistics

await client.fetchBehaviorStats({
    bot_id: 'bot-id'
});

Fetch Error Analysis

await client.fetchErrorAnalysis({
    bot_id: 'bot-id'
});

Fetch Reasoning Summary

await client.fetchReasoningSummary({
    bot_id: 'bot-id'
});

Response Format

All methods return a BoostGPTResponse object:

{
    err: null | Error,        // Error object if request failed
    response: null | Object   // Response data if request succeeded
}

Example error handling:

const result = await client.createBot({ name: 'My Bot' });

if (result.err) {
    console.error('Request failed:', result.err.message);
} else {
    console.log('Success:', result.response);
}

Development

Building the Package

# Install dependencies
npm install

# Build CommonJS files from ESM source
npm run build

The build process converts the ES Module source files in src/ to CommonJS in dist/.

Project Structure

  • src/ - ES Module source code (edit these files)
  • dist/ - Generated CommonJS build (don't edit, auto-generated)
  • build.js - Build script that transpiles ESM to CJS
  • package.json - Configured with "type": "module" and dual exports

Making Changes

  1. Edit files in src/ (ESM format)
  2. Run npm run build to generate CJS in dist/
  3. Test both ESM and CJS usage
  4. The prepublishOnly script automatically builds before publishing

TypeScript Support

While this package is written in JavaScript, it works with TypeScript. Type definitions may be added in a future release.

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes in src/
  4. Run npm run build
  5. Test both ESM and CJS usage
  6. Submit a Pull Request

License

MIT

Links

Support

For support, please visit the GitHub Issues page.

About

BoostGPT client library for nodejs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors