npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

infuseai-sdk

v1.1.0

Published

NPM Client for Infuse

Downloads

307

Readme

infuseai-sdk

The official Node.js client for InfuseAI. This SDK empowers you to seamlessly integrate your custom RAG apps and Knowledge Bases into any Node.js or frontend application.

📦 Installation

npm install infuseai-sdk

🚀 Usage

1. Import and Initialize

Initialize the InfuseClient with your application credentials. You can retrieve these from your App's dashboard in InfuseAI.

import { InfuseClient } from 'infuseai-sdk';

const client = new InfuseClient({
  clientId: 'YOUR_CLIENT_ID', // Your User ID
  appId: 'YOUR_APP_ID',       // The specific AI App ID
  apiKey: 'YOUR_API_KEY',     // The API Key for this App
  theme: 'minimal'            // Optional: 'minimal', 'gradient', 'bubble', etc.
});

2. Query Your App

Send prompts to your AI using the query method. The SDK manages context retrieval (RAG) and LLM inference behind the scenes.

async function askMyAssistant() {
  try {
    const response = await client.query('What does the documentation say about deployment?');
    
    console.log('Answer:', response.response);
    
    // If your app uses a Knowledge Base, you can inspect the sources used:
    if (response.sources) {
      console.log('Sources Used:', response.sources.map(s => s.name));
    }
  } catch (error) {
    console.error('Failed to query InfuseAI:', error.message);
  }
}

askMyAssistant();

3. Embed Chat Widget

You can easily embed the full chat interface into any DOM element using the mount method.

<!-- In your HTML -->
<div id="my-chat-container" style="height: 600px; width: 400px;"></div>

<script>
  client.mount("my-chat-container");
</script>

📘 API Reference

InfuseClient

Constructor

new InfuseClient(config: InfuseConfig)

InfuseConfig Properties:

| Property | Type | Required | Description | | :--------- | :------- | :------- | :---------- | | clientId | string | Yes | Your unique user identifier from the dashboard. | | appId | string | Yes | The ID of the specific app you want to interact with. | | apiKey | string | Yes | The secret API key for authentication. | | theme | string | No | Optional chat theme (default: 'minimal'). | | baseUrl | string | No | Optional override for the API endpoint (default: Production). |

client.query(text)

Sends a prompt to the InfuseAI backend.

Signature

query(text: string): Promise<QueryResponse>

Returns

A Promise resolving to a QueryResponse object:

interface QueryResponse {
  response: string;       // The AI's generated answer
  sources?: Array<{       // Optional list of sources used for RAG
    name: string;         // Name of the source file/document
    content: string;      // Snippet of the content used
  }>;
  [key: string]: any;
}

### `client.mount(elementId)`

Embeds the chat widget into the specified DOM element.

#### Signature

```typescript
mount(elementId: string): void

Parameters

| Parameter | Type | Description | | :---------- | :------- | :---------- | | elementId | string | The ID of the DOM element where the chat widget should be rendered. |

⚠️ Error Handling

The client will throw an error if:

  • Missing configuration (clientId, appId, apiKey).
  • Network issues prevent reaching the API.
  • The API returns 4xx or 5xx status codes (e.g., Invalid API Key).

Always wrap your calls in a try/catch block to handle these gracefully.

📄 License

ISC