API Reference
Events

Events

The BrowserAI instance emits events you can listen to:

browserAI.on('modelLoaded', (modelInfo) => {
  console.log(`Model ${modelInfo.name} loaded successfully`);
});
 
browserAI.on('error', (error) => {
  console.error('An error occurred:', error);
});

Available Events

EventDescription
modelLoadedTriggered when a model is successfully loaded
modelUnloadedTriggered when a model is unloaded
errorTriggered when an error occurs
progressTriggered during loading operations with progress updates

Example Usage

// Listen for loading progress
browserAI.on('progress', (progress) => {
  console.log(`Loading progress: ${progress.progress}%`);
});
 
// Handle model loading completion
browserAI.on('modelLoaded', (modelInfo) => {
  console.log(`Model ${modelInfo.name} is ready to use`);
});
 
// Global error handling
browserAI.on('error', (error) => {
  console.error('BrowserAI error:', error.message);
});