WebLLM runs large language model inference inside the web browser with WebGPU acceleration and no server-side processing. Developers integrate it via npm, yarn, or CDN and use an OpenAI-compatible API.
Overview
WebLLM is an in-browser inference engine that brings language model execution onto the client with hardware acceleration through WebGPU. Inference stays on the user’s device instead of relying on a remote inference cluster, which the project positions as a path toward lower cost, personalization, and stronger privacy for AI assistants in web experiences.
The package exposes a modular interface centered on MLCEngine, which you create and use to load models and request chat completions. It mirrors the OpenAI chat API, including streaming responses, JSON mode, logit-level control, seeding, and preliminary function-calling support. Applications can offload work to dedicated web workers or service workers so heavy computation does not block the UI, and examples cover Chrome extensions as well as ordinary web pages.
WebLLM ships with built-in support for many open model families, including Llama, Phi, Gemma, Mistral, and Qwen, with a fuller catalog documented separately. Custom weights in MLC format can be integrated by supplying model artifact URLs and matching WebAssembly model libraries, reusing the same deployment flow as the related MLC LLM project.
You install WebLLM through npm or yarn, import it in application code, or load it from a CDN on platforms such as jsfiddle or CodePen. Optional integrity verification can check downloaded configs, WASM, and tokenizer files against Subresource Integrity hashes before models load. Several cache backends are available for stored artifacts, including options that depend on browser storage APIs or a compatible cross-origin extension.
Key features
- WebGPU-accelerated in-browser inference
- OpenAI-compatible chat completion API
- Streaming and JSON-mode responses
- Built-in Llama, Phi, Gemma, Mistral, and Qwen models
- Custom MLC-format model integration
- Web worker and service worker engines
- npm, yarn, and CDN installation
- Optional SRI integrity verification for model files
Use cases
- Privacy-focused browser chatbots
- Local OpenAI-style APIs in web apps
- Chrome extensions with on-device LLMs
- Offline-capable assistants via service workers
- Interactive streaming chat UIs