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

ai-widget-pro

v1.0.3

Published

Universal AI widget for websites. Supports OpenAI, Gemini, Anthropic, xAI, Meta/LLaMA, Mistral, DeepSeek, Alibaba, and custom providers. Streaming, multi-modal, and framework-agnostic.

Readme

AI Widget

A universal AI widget for websites. Supports OpenAI, Gemini, Anthropic, xAI, Meta/LLaMA, Mistral, DeepSeek, Alibaba, and custom AI providers.

Features streaming responses, multi-modal inputs (voice, file, image), persistent sessions, analytics, and framework-agnostic usage. Works with React, Vue, Angular, Svelte, or vanilla JS.


Features

Core AI

  • Text completion / generation
  • Chatbot conversations (multi-turn)
  • Summarization, paraphrasing, translation
  • Code assistance: completion, debugging hints, language conversion

Streaming & Real-Time

  • Streaming responses from providers like OpenAI
  • Real-time incremental updates
  • Typing animation simulation
  • Progress callbacks

Multi-Modal

  • Voice input (speech-to-text) and output (text-to-speech)
  • File analysis (PDF, TXT, JSON)
  • Image generation and analysis

Frontend Integration

  • Framework-agnostic
  • React hooks and components
  • Vanilla JS support
  • Custom themes and UI options

Data & State

  • Persistent conversation history (localStorage)
  • Optional session-based context
  • Analytics & logging support
  • Rate-limiting / queueing for multiple users

Developer Experience

  • TypeScript ready
  • Supports fetch, axios, or custom API clients
  • Easy to extend for new providers
  • Fully documented API

Installation

npm install ai-widget-pro
# or
yarn add ai-widget-pro

Quick Start

import { complete } from "ai-widget-pro";

const config = {
  provider: "<end-point-link>",
  apiKey: "YOUR_OPENAI_KEY",
  model: "eg. gpt-4 or gpt-3.5-turbo ..."
};

const response = await complete({
  prompt: "Hello AI",
  providerConfig: config
});

console.log("AI Response:", response);

Examples

1. Text Completion

const response = await complete({
  prompt: "Write a short poem about AI and nature",
  providerConfig: config
});
console.log(response);

2. Streaming Example

import { stream } from "ai-widget-pro";

stream({
  prompt: "Explain quantum computing in simple words",
  providerConfig: config,
  onUpdate: (chunk) => process.stdout.write(chunk)
});

3. Voice Support

Text-to-Speech

import { speak } from "ai-widget-pro";
speak("Hello world! This is AI speaking.");

Speech-to-Text

import { startVoiceInput } from "ai-widget-pro";
startVoiceInput((text) => console.log("Recognized speech:", text));

4. File Analysis

import { analyzeFile } from "ai-widget-pro";

const file = new File(["This document explains AI basics"], "ai.txt");

const result = await analyzeFile(file, {
  prompt: "Summarize this document in one paragraph",
  providerConfig: config
});

console.log(result);

5. Image Generation

import { generateImage } from "ai-widget-pro";

const imageUrl = await generateImage("A futuristic city skyline at sunset", {
  prompt: "",
  providerConfig: config
});

console.log("Generated image URL:", imageUrl);

6. Conversation Storage

import { saveConversation, loadConversation } from "ai-widget-pro";

saveConversation("session123", ["Hello AI", "Hi! How can I help you?"]);

const history = loadConversation("session123");
console.log(history);

7. Analytics Logging

import { logEvent } from "ai-widget-pro";

logEvent("message_sent", { prompt: "Hello AI" });
logEvent("voice_input_started");

8. Custom Provider Example

import axios from "axios";
import { complete } from "ai-widget-pro";

const customConfig = {
  provider: "custom",
  apiKey: "",
  apiClient: axios
};

const response = await complete({
  prompt: "Custom AI API test",
  providerConfig: customConfig
});

console.log(response);

9. React Integration

import React, { useState, useEffect } from "react";
import { complete } from "ai-widget-pro";

const AIChat = () => {
  const [response, setResponse] = useState("");

  useEffect(() => {
    complete({ 
      prompt: "Hello from React!", 
      providerConfig: config 
    }).then(setResponse);
  }, []);

  return <div>{response}</div>;
};

export default AIChat;

10. Vue Integration

<template>
  <div>{{ aiResponse }}</div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { complete } from "ai-widget-pro";

const aiResponse = ref("");

onMounted(async () => {
  aiResponse.value = await complete({ 
    prompt: "Hello from Vue!", 
    providerConfig: config 
  });
});
</script>

11. Vanilla JS Integration

<script type="module">
  import { complete } from "./dist/index.js";

  const config = {
    provider: "openai",
    apiKey: "YOUR_OPENAI_KEY",
    model: "gpt-4"
  };

  const output = await complete({ 
    prompt: "Hello Vanilla JS!", 
    providerConfig: config 
  });
  
  document.body.innerText = output;
</script>

API Reference

Core Functions

| Function | Description | Parameters | |----------|-------------|------------| | complete() | Text completion/generation | prompt, providerConfig | | stream() | Streaming responses | prompt, providerConfig, onUpdate | | speak() | Text-to-speech | text, options | | startVoiceInput() | Speech-to-text | callback, options | | analyzeFile() | File analysis | file, prompt, providerConfig | | generateImage() | Image generation | prompt, providerConfig |

Configuration

const config = {
  provider: "openai" | "gemini" | "anthropic" | "custom",
  apiKey: "your-api-key",
  model: "gpt-4" | "gemini-pro" | "claude-3",
  apiClient?: axios | fetch | custom
};

Streaming Flow Diagram

User Input → AI Widget → Provider API → Streaming Response → UI Update
     ↓           ↓            ↓              ↓               ↓
   Prompt    Validation   HTTP Request   Chunk Received   onUpdate()

File/Voice/Image Processing Flow

Input (File/Voice/Image) → Processing → AI Analysis → Output
         ↓                     ↓           ↓          ↓
    Format Detection    Conversion    API Call    Results

Provider Support

| Provider | Text | Streaming | Voice | Images | |----------|------|-----------|-------|--------| | OpenAI | ✅ | ✅ | ✅ | ✅ | | Gemini | ✅ | ⚠️ | ⚠️ | ✅ | | Anthropic | ✅ | ⚠️ | ⚠️ | ❌ | | xAI | ✅ | ⚠️ | ❌ | ❌ | | Custom | ✅ | ✅ | ✅ | ✅ |

✅ Supported | ⚠️ Fallback | ❌ Not Available


Notes

  • Streaming is currently supported for OpenAI. Other providers fallback to normal completion.
  • Multi-modal features like image generation are stubbed and can be extended for other AI models.
  • Works with any HTTP client: fetch, axios, or custom implementations.
  • Fully compatible with modern browsers and Node.js.
  • TypeScript definitions included for better developer experience.


License

MIT License © 2025


Changelog

v1.0.0

  • Initial release
  • Core AI functionality
  • Multi-provider support
  • Framework integrations


Built with ❤️ for developers who want powerful AI integration made simple.