Cybernate
    • Cybernate AI SDK

    Cybernate AI SDK

    npm version
    License
    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#

    Get your API key from the Cybernate dashboard.

    AI — Chat#

    Options#

    OptionTypeDefaultDescription
    modelstring'default'Model ID
    maxTokensnumber400Max tokens to generate
    temperaturenumber0.7Sampling 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?)#

    OptionTypeDefaultDescription
    baseUrlstringhttps://api.cybernate.ai/v1API base URL
    timeoutnumber30000Request timeout (ms)
    autoReconnectbooleantrueAuto-reconnect WebSocket
    enableWebSocketbooleantrueEnable WebSocket for real-time events
    reconnectAttemptsnumber5Max reconnect attempts
    reconnectDelaynumber1000Delay between attempts (ms)

    Core#

    MethodDescription
    connect()Validate API key and open WebSocket (optional)
    disconnect()Close connection and clean up
    getConnectionStatus()Returns { isConnected, websocketConnected, activeWatchers }

    AI#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MethodDescription
    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#

    MIT
    Modified at 2026-05-18 01:53:55
    Built with