首次使用需下载模型,之后才能离线运行;部分模型依赖硬件支持 shader-f16,不满足时无法加载;Demucs 需从 @browserai/browserai/demucs 单独导入。

BrowserAI
sauravpandaMIT活跃维护在浏览器里直接跑 llama、deepseek-distill、kokoro 等本地大模型和语音合成,靠 WebGPU 加速,不用装后端也不用上传数据。
Run local LLMs like llama, deepseek-distill, kokoro and more inside your browser
npm install @browserai/browserai需要支持 WebGPU 的现代浏览器(Chrome 113+、Edge 113+ 或同等);要求 shader-f16 的模型还需硬件支持 16 位浮点运算。README 未说明显存或 CPU 运行要求。
在浏览器里本地跑 LLM、语音识别与 TTS 的开源 SDK,无需服务器
在浏览器里直接跑 llama、deepseek-distill、kokoro 等本地大模型和语音合成,靠 WebGPU 加速,不用装后端也不用上传数据。
核心能力
- 用 WebGPU 加速浏览器内推理,接近原生性能
- 支持 MLC、Transformers、Flare、Demucs 多引擎切换
- 预置 Llama、Qwen、Gemma、DeepSeek 蒸馏等常用模型
- 支持 JSON Schema 结构化输出与系统提示词对话
- 内置 Whisper 语音识别、Kokoro TTS 与 Demucs 音轨分离
容易踩的坑
- v2.2.0最新正式版2026-04-18 · 2026-04-18 00:26 UTC
What's New
Engine Comparison Benchmark
New
examples/benchmark/demo that compares MLC (WebGPU), Transformers.js (ONNX/WASM), and Flare (GGUF/WASM) engines side-by-side. Measures model load time, TTFT, and tokens/sec with configurable runs and visual charts.Flare Engine Updates
- Package rename:
@aspect/flare→@sauravpanda/flare(the actual published npm package) - Installed as dependency:
@sauravpanda/[email protected] - Fixed model URLs: SmolLM2 GGUF models now use bartowski's public HuggingFace repos
Housekeeping
- Jest 29 → 30: Clears all 4 npm audit vulnerabilities in the main package
- README: Documents Demucs (audio source separation) and Flare (GGUF/WASM) engines with usage examples
- Tests: 62 passing tests across 7 suites (up from 35)
- 14 issues closed via triage and fixes
Full Changelog
https://github.com/sauravpanda/BrowserAI/compare/v2.1.1...v2.2.0
- Package rename:
- v2.0.42025-05-21 · 2025-05-21 19:17 UTC
查看更新说明
What's Changed
- 187 make html cleaner more robust by @shreyashkgupta in https://github.com/sauravpanda/BrowserAI/pull/189
- feat: added qwen3 thinking model support by @sauravpanda in https://github.com/sauravpanda/BrowserAI/pull/194
- release: new package version 2.0.4 by @sauravpanda in https://github.com/sauravpanda/BrowserAI/pull/196
Full Changelog: https://github.com/sauravpanda/BrowserAI/compare/v2.0.2...v2.0.4
- v2.0.22025-04-15 · 2025-04-15 18:01 UTC
查看更新说明
What's Changed
- build(deps): bump next from 14.2.23 to 14.2.26 in /docs by @dependabot in https://github.com/Cloud-Code-AI/BrowserAI/pull/176
- Added featured banner for BrowserAgent on open source repo by @sauravpanda in https://github.com/Cloud-Code-AI/BrowserAI/pull/180
- Streaming Change by @manmohan659 in https://github.com/Cloud-Code-AI/BrowserAI/pull/181
- removed posthog default tracking by @sauravpanda in https://github.com/Cloud-Code-AI/BrowserAI/pull/183
- refc: removed posthog tracking by @sauravpanda in https://github.com/Cloud-Code-AI/BrowserAI/pull/185
- fix: updated html cleaning logic for textarea by @shreyashkgupta in https://github.com/Cloud-Code-AI/BrowserAI/pull/188
Full Changelog: https://github.com/Cloud-Code-AI/BrowserAI/compare/v2.0.0...v2.0.2
- v2.0.02025-03-27 · 2025-03-27 06:35 UTC
查看更新说明
What's Changed
- made default response openai compatible by @sauravpanda in https://github.com/Cloud-Code-AI/BrowserAI/pull/175
Full Changelog: https://github.com/Cloud-Code-AI/BrowserAI/compare/v1.0.37...v2.0.0
- v1.0.372025-03-19 · 2025-03-19 17:20 UTC
查看更新说明
What's Changed
- 171 add auto cache clearing by @shreyashkgupta in https://github.com/Cloud-Code-AI/BrowserAI/pull/172
- feat: Updated chat demo by @shreyashkgupta in https://github.com/Cloud-Code-AI/BrowserAI/pull/173
Full Changelog: https://github.com/Cloud-Code-AI/BrowserAI/compare/v1.0.36...v1.0.37
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
BrowserAI 🚀
Run Production-Ready LLMs Directly in Your Browser
Live Demo • Documentation • Discord 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, Transformers, Flare, and Demucs 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
- 🎵 Audio source separation (Demucs) - isolate vocals, drums, bass, and other stems
- 💾 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);
});
Audio Source Separation (Demucs)
import { DemucsEngine } from '@browserai/browserai/demucs';
const engine = new DemucsEngine();
await engine.loadModel({ /* htdemucs config */ });
// Separate an AudioBuffer into stems
const result = await engine.separate(audioBuffer, {
shifts: 1, // Time-shift augmentation passes (higher = better quality, slower)
overlap: 0.25, // Segment overlap ratio
});
// result.sources contains: drums, bass, other, vocals (each as AudioBuffer)
const vocals = result.sources['vocals'];
Flare Engine (GGUF Models via WASM)
const ai = new BrowserAI();
// Load a GGUF model via the Flare engine
await ai.loadModel('llama-3.2-1b-flare');
// Generate text — same API as MLC/Transformers
const response = await ai.generateText('Explain quantum computing briefly');
// Optional: Load a LoRA adapter
await ai.loadAdapter({ url: 'https://example.com/adapter.safetensors' });
🔧 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)
Flare Models (GGUF via WASM)
- SmolLM2-135M-Instruct (Q8_0, Q4_K_M)
- SmolLM2-360M-Instruct (Q8_0)
- Qwen2.5-0.5B-Instruct (Q4_K_M)
- Llama-3.2-1B-Instruct (Q8_0, Q4_K_M)
Demucs Models (Audio Source Separation)
- HTDemucs (4-stem: drums, bass, other, vocals)
🗺️ 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:
- 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
📄 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.
- Facebook Research for Demucs, the state-of-the-art music source separation model.
- Aspect for the Flare WASM inference engine enabling GGUF model support in the browser.
- All our contributors and supporters!
🚀 Requirements
- Modern browser with WebGPU support (Chrome 113+, Edge 113+, or equivalent)
- For models with
shader-f16requirement, hardware must support 16-bit floating point operations