Docs
JavaScript SDK

JavaScript SDK

Official Node.js/TypeScript SDK for the Lumnis AI API

Overview

The official JavaScript/TypeScript SDK for Lumnis AI provides a modern, type-safe interface for building AI-powered applications. Built with ES modules and full async/await support.

Features

  • 📦 TypeScript First - Complete type safety and autocompletion
  • Modern Architecture - Built with ES modules and async/await
  • 📁 File Management - Upload, search, and manage files with semantic search
  • 🔄 Automatic Retries - Smart retry logic with exponential backoff
  • 🎯 Idempotent Requests - Built-in idempotency for safe retries
  • 📊 Response Polling - Easy helpers for async response handling
  • 🔐 Secure by Default - API key authentication with secure storage
  • 🔌 MCP Integration - Full support for Model Context Protocol servers
  • 🎨 Advanced Agent Config - Granular control over agent behavior

Installation

npm install lumnisai
yarn add lumnisai
pnpm add lumnisai

Quick Start

import { LumnisClient, displayProgress } from 'lumnisai'
 
// Initialize the client
const client = new LumnisClient({
  apiKey: process.env.LUMNISAI_API_KEY!
})
 
// Or use environment variables (LUMNISAI_API_KEY)
// const client = new LumnisClient()
 
// Create a simple response
const response = await client.invoke("What is the meaning of life?")
console.log(response.outputText)
 
// With streaming
for await (const update of await client.invoke(
  "Explain quantum computing",
  { stream: true }
)) {
  displayProgress(update)
  
  if (update.state === 'completed') {
    console.log(`\n${update.outputText}`)
  }
}

Configuration

Environment Variables

export LUMNISAI_API_KEY="your-api-key"
export LUMNISAI_TENANT_ID="your-tenant-id"  # Optional

Client Initialization

import { LumnisClient } from 'lumnisai'
 
// Using API key directly
const client = new LumnisClient({
  apiKey: 'your-api-key'
})
 
// Using environment variables (LUMNISAI_API_KEY)
const client = new LumnisClient()
 
// Custom configuration
const client = new LumnisClient({
  apiKey: 'your-api-key',
  timeoutMs: 60000,   // 60 second timeout
  maxRetries: 3       // Retry up to 3 times
})

User-Scoped Operations

import { LumnisClient } from 'lumnisai'
 
const client = new LumnisClient({ apiKey: process.env.LUMNISAI_API_KEY! })
 
// Create a user-scoped client
const userClient = client.forUser("user@example.com")
const response = await userClient.invoke("What's the weather?")
 
// All operations now scoped to this user
const threads = await userClient.listThreads()

Next Steps

Explore the different SDK capabilities:

Support

License

MIT License © Lumnis AI