Overview
Create a basic AI agent using the BoostGPT Core SDK in under 5 minutes.Prerequisites
npm install boostgpt
Complete Example
import { BoostGPT } from 'boostgpt';
// Initialize client
const client = new BoostGPT({
key: process.env.BOOSTGPT_API_KEY,
project_id: process.env.BOOSTGPT_PROJECT_ID
});
async function main() {
// 1. Create a bot
console.log('Creating bot...');
const botResult = await client.createBot({
name: 'Customer Support Assistant',
model: 'gpt-5.6-luna',
instruction: 'You are a helpful customer support agent. Be friendly and concise.'
});
if (botResult.err) {
console.error('Error creating bot:', botResult.err);
return;
}
const botId = botResult.response.id;
console.log('Bot created:', botId);
// 2. Add training data
console.log('\nAdding training data...');
const trainingResult = await client.startTraining({
bot_id: botId,
type: 'text',
source: `
Q: What are your business hours?
A: We're open Monday-Friday, 9am-5pm EST.
Q: How do I reset my password?
A: Click "Forgot Password" on the login page and follow the instructions.
Q: What's your return policy?
A: We accept returns within 30 days of purchase.
`
});
if (trainingResult.err) {
console.error('Error adding training:', trainingResult.err);
return;
}
console.log('Training queued:', trainingResult.response.id);
// Wait for training to process
console.log('Waiting for training to complete...');
await new Promise(resolve => setTimeout(resolve, 3000));
// 3. Chat with bot
console.log('\nTesting bot...');
const chatResult = await client.chat({
bot_id: botId,
message: 'What are your business hours?',
chat_id: 'user-123'
});
if (chatResult.err) {
console.error('Error chatting:', chatResult.err);
return;
}
console.log('Bot response:', chatResult.response);
}
main();
Step-by-Step Breakdown
1. Initialize Client
import { BoostGPT } from 'boostgpt';
const client = new BoostGPT({
key: process.env.BOOSTGPT_API_KEY,
project_id: process.env.BOOSTGPT_PROJECT_ID
});
2. Create Bot
const botResult = await client.createBot({
name: 'Customer Support Assistant',
model: 'gpt-5.6-luna',
instruction: 'You are a helpful customer support agent.'
});
const botId = botResult.response.id;
3. Add Training Data
await client.startTraining({
bot_id: botId,
type: 'text',
source: 'Your training content here...'
});
4. Chat with Bot
const chatResult = await client.chat({
bot_id: botId,
message: 'User question',
chat_id: 'user-123'
});
console.log(chatResult.response);
Running the Example
# Set API key
export BOOSTGPT_API_KEY=your_api_key
# Run
node basic-bot.js
Creating bot...
Bot created: bot_abc123
Adding training data...
Training queued: source_xyz789
Waiting for training to complete...
Testing bot...
Bot response: We're open Monday-Friday, 9am-5pm EST.
Adding More Features
Stream Responses
const chatResult = await client.chat({
bot_id: botId,
message: 'Tell me about your services',
stream: true
});
// Handle streaming
for await (const chunk of chatResult.response) {
process.stdout.write(chunk);
}
Multiple Training Sources
// Add FAQ
await client.startTraining({
bot_id: botId,
type: 'text',
source: 'FAQ content...'
});
// Add from website
await client.startTraining({
bot_id: botId,
type: 'website',
source: 'https://example.com'
});
// Add files
await client.startTraining({
bot_id: botId,
type: 'file',
source: ['manual.pdf', 'guide.docx']
});
Custom Model Settings
const chatResult = await client.chat({
bot_id: botId,
message: 'Question',
model: 'gpt-5.6-luna', // Override model
max_reply_tokens: 500, // Limit response length
reasoning_mode: 'agent' // Autonomous multi-step reasoning
});
Error Handling
Always handle errors:const result = await client.createBot({
name: 'My Bot',
model: 'gpt-5.6-luna'
});
if (result.err) {
console.error('Error:', result.err);
// Handle error
return;
}
// Use result.response
const botId = result.response.id;
Next Steps
Multi-Channel Bot
Deploy bot to multiple platforms
With Integrations
Add custom tools and integrations
SDK Reference
Full SDK documentation
API Reference
REST API documentation