JavaScript SDK for the Cybernate AI platform — general-purpose AI inference built for Africa. Chat, multi-turn conversations, embeddings, vision, and security monitoring in one client.Installation#
Quick Start#
AI — Chat#
Options#
| Option | Type | Default | Description |
|---|
model | string | 'default' | Model ID |
maxTokens | number | 400 | Max tokens to generate |
temperature | number | 0.7 | Sampling temperature (0–1) |
AI — Conversations#
Server-managed history — no need to replay the full thread on each call.
AI — Embeddings#
AI — Vision / Object Detection#
Security Monitoring#
API Reference#
Constructor#
new CybernateAI(apiKey, options?)#
| Option | Type | Default | Description |
|---|
baseUrl | string | https://api.cybernate.ai/v1 | API base URL |
timeout | number | 30000 | Request timeout (ms) |
autoReconnect | boolean | true | Auto-reconnect WebSocket |
enableWebSocket | boolean | true | Enable WebSocket for real-time events |
reconnectAttempts | number | 5 | Max reconnect attempts |
reconnectDelay | number | 1000 | Delay between attempts (ms) |
Core#
| Method | Description |
|---|
connect() | Validate API key and open WebSocket (optional) |
disconnect() | Close connection and clean up |
getConnectionStatus() | Returns { isConnected, websocketConnected, activeWatchers } |
| Method | Description |
|---|
chat(messages, options?) | One-shot inference |
embed(texts, model?) | Generate vector embeddings |
detectObjects(options) | Object detection on an image |
listModels() | List available local and remote models |
Conversations#
| Method | Description |
|---|
createConversation(title?) | Create a new conversation |
listConversations() | List all conversations |
getConversation(id) | Get conversation with messages |
updateConversation(id, updates) | Update title or pinned state |
deleteConversation(id) | Delete conversation and messages |
sendMessage(id, content, options?) | Send a message and get AI reply |
rateMessage(convId, msgId, rating) | Rate a message 'up', 'down', or null |
Security Monitoring#
| Method | Description |
|---|
watch(options) | Start watching a stream, device, or business |
unwatch(watcherId) | Stop a watcher |
getActiveWatchers() | List active watchers |
queryEvents(query?) | Search events with filters + pagination |
getEventStatistics(query?) | Aggregate event statistics |
acknowledgeEvent(eventId, notes?) | Mark event as acknowledged |
on(event, callback) | Register real-time event listener |
off(event, callback?) | Remove event listener |
Webhooks#
| Method | Description |
|---|
setWebhook(config) | Configure a webhook URL and event types |
getWebhooks() | List all webhooks |
deleteWebhook(webhookId) | Delete a webhook |
testWebhook(url, payload?) | Send a test payload to a webhook |
Storage#
| Method | Description |
|---|
uploadFile(options) | Upload a file |
getFileInfo(fileId) | Get file metadata |
queryFiles(query?) | Search files with filters |
deleteFile(fileId) | Delete a file |
getFileUrl(fileId, expiresIn?) | Get a signed URL |
captureStreamFrame(streamId, options?) | Capture a frame from a stream |
Analytics#
| Method | Description |
|---|
getAnalytics(businessId, options?) | Daily / weekly / monthly analytics |
getInsights(businessId, options?) | AI-generated insights |
acknowledgeInsight(insightId, actionTaken?) | Mark insight as actioned |
getDashboardAnalytics(businessId) | Dashboard summary |
Integrations#
| Method | Description |
|---|
getIntegrations(query?) | List integrations |
createIntegration(data) | Create an integration |
getIntegration(id) | Get integration by ID |
updateIntegration(id, data) | Update an integration |
deleteIntegration(id) | Delete an integration |
testIntegration(id) | Test an integration connection |
triggerIntegration(id, action, data?) | Trigger an integration action |
Notifications#
| Method | Description |
|---|
getNotifications(options?) | List notifications |
markNotificationAsRead(id) | Mark one as read |
markAllNotificationsAsRead() | Mark all as read |
getNotificationPreferences() | Get preferences |
updateNotificationPreferences(prefs) | Update preferences |
addDeviceToken(token) | Register push token |
removeDeviceToken(token) | Remove push token |
Complete Example#
Error Handling#
Errors include descriptive messages for 401 Authentication failed, 403 Access forbidden, 404 Not found, and 5xx Server error.
Browser Support#
Works in all modern browsers and Node.js ≥ 16. The cross-fetch dependency is included automatically for Node.js. WebSocket support requires socket.io-client (optional peer dependency — only needed for real-time event streaming).License#
Modified at 2026-05-18 01:53:55