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

@browserai/browserai

v2.0.4

Published

A library for running AI models directly in the browser

Readme

BrowserAI 🚀

Run Production-Ready LLMs Directly in Your Browser

Live DemoDocumentationDiscord Community

🎉 Featured Project: Check out Browseragent.dev - A no-code AI Agent builder powered by BrowserAI with unlimited executions! Build your own AI agents in minutes.

🌟 Live Demos

| Demo | Description | Try It | |------|-------------|--------| | Chat | Multi-model chat interface | chat.browserai.dev | | Voice Chat | Full-featured with speech recognition & TTS | voice-demo.browserai.dev | | Text-to-Speech | Powered by Kokoro 82M | tts-demo.browserai.dev |

⚡ Key Features

  • 🔒 100% Private: All processing happens locally in your browser
  • 🚀 WebGPU Accelerated: Near-native performance
  • 💰 Zero Server Costs: No complex infrastructure needed
  • 🌐 Offline Capable: Works without internet after initial download
  • 🎯 Developer Friendly: Simple sdk with multiple engine support
  • 📦 Production Ready: Pre-optimized popular models

🎯 Perfect For

  • Web developers building AI-powered applications
  • Companies needing privacy-conscious AI solutions
  • Researchers experimenting with browser-based AI
  • Hobbyists exploring AI without infrastructure overhead
  • No-code platform builders creating AI-powered tools

✨ Features

  • 🎯 Run AI models directly in the browser - no server required!
  • ⚡ WebGPU acceleration for blazing fast inference
  • 🔄 Seamless switching between MLC and Transformers engines
  • 📦 Pre-configured popular models ready to use
  • 🛠️ Easy-to-use API for text generation and more
  • 🔧 Web Worker support for non-blocking UI performance
  • 📊 Structured output generation with JSON schemas
  • 🎙️ Speech recognition and text-to-speech capabilities
  • 💾 Built-in database support for storing conversations and embeddings

🚀 Quick Start

npm install @browserai/browserai

OR

yarn add @browserai/browserai

Basic Usage

import { BrowserAI } from '@browserai/browserai';

const browserAI = new BrowserAI();

// Load model with progress tracking
await browserAI.loadModel('llama-3.2-1b-instruct', {
  quantization: 'q4f16_1',
  onProgress: (progress) => console.log('Loading:', progress.progress + '%')
});

// Generate text
const response = await browserAI.generateText('Hello, how are you?');
console.log(response.choices[0].message.content);

📚 Examples

Text Generation with Options

const response = await browserAI.generateText('Write a short poem about coding', {
  temperature: 0.8,
  max_tokens: 100,
  system_prompt: "You are a creative poet specialized in technology themes."
});

Chat with System Prompt

const ai = new BrowserAI();
await ai.loadModel('gemma-2b-it');

const response = await ai.generateText([
  { role: 'system', content: 'You are a helpful assistant.' },
  { role: 'user', content: 'What is WebGPU?' }
]);

Chat with System Prompt

const response = await browserAI.generateText('List 3 colors', {
  json_schema: {
    type: "object",
    properties: {
      colors: {
        type: "array",
        items: {
          type: "object",
          properties: {
            name: { type: "string" },
            hex: { type: "string" }
          }
        }
      }
    }
  },
  response_format: { type: "json_object" }
});

Speech Recognition

const browserAI = new BrowserAI();
await browserAI.loadModel('whisper-tiny-en');

// Using the built-in recorder
await browserAI.startRecording();
const audioBlob = await browserAI.stopRecording();
const transcription = await browserAI.transcribeAudio(audioBlob, {
  return_timestamps: true,
  language: 'en'
});

Text-to-Speech

const ai = new BrowserAI();
await ai.loadModel('kokoro-tts');
const audioBuffer = await browserAI.textToSpeech('Hello, how are you today?', {
  voice: 'af_bella',
  speed: 1.0
});// Play the audio using Web Audio API
const audioContext = new AudioContext();
const source = audioContext.createBufferSource();
audioContext.decodeAudioData(audioBuffer, (buffer) => {
  source.buffer = buffer;
  source.connect(audioContext.destination);
  source.start(0);
});

🔧 Supported Models

More models will be added soon. Request a model by creating an issue.

MLC Models

  • Llama-3.2-1b-Instruct
  • Llama-3.2-3b-Instruct
  • Hermes-Llama-3.2-3b
  • SmolLM2-135M-Instruct
  • SmolLM2-360M-Instruct
  • SmolLM2-1.7B-Instruct
  • Qwen-0.5B-Instruct
  • Gemma-2B-IT
  • TinyLlama-1.1B-Chat-v0.4
  • Phi-3.5-mini-instruct
  • Qwen3-0.6B
  • Qwen3-1.7B
  • Qwen3-4B
  • Qwen3-8B
  • Qwen2.5-1.5B-Instruct
  • DeepSeek-R1-Distill-Qwen-7B
  • DeepSeek-R1-Distill-Llama-8B
  • Snowflake-Arctic-Embed-M-B32
  • Snowflake-Arctic-Embed-S-B32
  • Snowflake-Arctic-Embed-M-B4
  • Snowflake-Arctic-Embed-S-B4

Transformers Models

  • Llama-3.2-1b-Instruct
  • Whisper-tiny-en (Speech Recognition)
  • Whisper-base-all (Speech Recognition)
  • Whisper-small-all (Speech Recognition)
  • Kokoro-TTS (Text-to-Speech)

🗺️ Enhanced Roadmap

Phase 1: Foundation

  • 🎯 Simplified model initialization
  • 📊 Basic monitoring and metrics
  • 🔍 Simple RAG implementation
  • 🛠️ Developer tools integration

Phase 2: Advanced Features

  • 📚 Enhanced RAG capabilities
    • Hybrid search
    • Auto-chunking
    • Source tracking
  • 📊 Advanced observability
    • Performance dashboards
    • Memory profiling
    • Error tracking

Phase 3: Enterprise Features

  • 🔐 Security features
  • 📈 Advanced analytics
  • 🤝 Multi-model orchestration

🤝 Contributing

We welcome contributions! Feel free to:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • MLC AI for their incredible mode compilation library and support for webgpu runtime and xgrammar
  • Hugging Face and Xenova for their Transformers.js library, licensed under Apache License 2.0. The original code has been modified to work in a browser environment and converted to TypeScript.
  • All our contributors and supporters!

🚀 Requirements

  • Modern browser with WebGPU support (Chrome 113+, Edge 113+, or equivalent)
  • For models with shader-f16 requirement, hardware must support 16-bit floating point operations