2025-01-22 12:40:00
github.com
BrowserAI: Run LLMs in the Browser – Simple, Fast, and Open Source!
- π Privacy First: All processing happens locally – your data never leaves the browser
- π° Cost Effective: No server costs or complex infrastructure needed
- π Offline Capable: Models work offline after initial download
- π Blazing Fast: WebGPU acceleration for near-native performance
- π― Developer Friendly: Simple API, multiple engine support, ready-to-use models
- Web developers building AI-powered applications
- Companies needing privacy-conscious AI solutions
- Researchers experimenting with browser-based AI
- Hobbyists exploring AI without infrastructure overhead
- π― 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
Demo | Description | URL | Status |
---|---|---|---|
Chat Demo | Simple chat interface with multiple model options | Try Chat Demo | β |
Voice Chat Demo | Full-featured demo with speech recognition and text-to-speech | Try Voice Demo | β |
bash
npm install @browserai/browserai
OR
bash
yarn add @browserai/browserai
import { BrowserAI } from '@browserai/browserai';
const browserAI = new BrowserAI();
browserAI.loadModel('llama-3.2-1b-instruct');
const response = await browserAI.generateText('Hello, how are you?');
console.log(response);
const ai = new BrowserAI();
await ai.loadModel('llama-3.2-1b-instruct', {
quantization: 'q4f16_1' // Optimize for size/speed
});
const response = await ai.generateText('Write a short poem about coding', {
temperature: 0.8,
maxTokens: 100
});
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?' }
]);
const ai = new BrowserAI();
await ai.loadModel('whisper-tiny-en');
// Using the built-in recorder
await ai.startRecording();
const audioBlob = await ai.stopRecording();
const transcription = await ai.transcribeAudio(audioBlob);
const ai = new BrowserAI();
await ai.loadModel('speecht5-tts');
const audioBuffer = await ai.textToSpeech('Hello, how are you today?');
// 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);
});
More models will be added soon. Request a model by creating an issue.
- Llama-3.2-1b-Instruct
- 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
- Qwen2.5-1.5B-Instruct
- Llama-3.2-1b-Instruct
- Whisper-tiny-en (Speech Recognition)
- SpeechT5-TTS (Text-to-Speech)
- π― Simplified model initialization
- π Basic monitoring and metrics
- π Simple RAG implementation
- π οΈ Developer tools integration
- π Enhanced RAG capabilities
- Hybrid search
- Auto-chunking
- Source tracking
- π Advanced observability
- Performance dashboards
- Memory profiling
- Error tracking
- π Security features
- π Advanced analytics
- π€ Multi-model orchestration
We welcome contributions! Feel free to:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License – see the LICENSE file for details.
- 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!
Made with β€οΈ for the AI community
- 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
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Support Techcratic
If you find value in Techcraticβs insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.