A machine learning compiler and deployment engine that runs large language models natively across GPUs, browsers, and mobile devices with OpenAI-compatible APIs.
mlc-ai/web-llm
A TypeScript engine that runs LLM inference entirely in the browser using WebGPU, with an OpenAI-compatible API.
- Stars
- 19,291
- Forks
- 1,401
- Open issues
- 154
- Last commit
- 10 days ago
What is it?
WebLLM is an in-browser inference engine for large language models. Inference runs entirely on the client with no server involved, and it uses WebGPU for hardware acceleration. It is distributed as an npm package (@mlc-ai/web-llm) and can also be loaded directly from a CDN.
The engine exposes the same chat completion interface as the OpenAI API, so existing OpenAI-style code can target open models running locally in the browser. It supports streaming responses, JSON-mode output, seeded generation, and logit-level control. Function calling is listed as work in progress.
Models are used in the MLC format, and the project supports families such as Llama 3, Phi 3, Gemma, Mistral, and Qwen. Developers can run the engine in a dedicated Web Worker or Service Worker, or inside a Chrome extension, and can configure browser cache backends such as Cache API, IndexedDB, and OPFS.
Key features
- 01Runs LLM inference in the browser with WebGPU acceleration and no server.
- 02Provides an OpenAI-compatible chat completions API with streaming and JSON mode.
- 03Supports models such as Llama 3, Phi 3, Gemma, Mistral, and Qwen in MLC format.
- 04Can run in Web Workers, Service Workers, or Chrome extensions.
- 05Offers SRI-based integrity verification for downloaded model artifacts.
Use cases
- Building a privacy-preserving chatbot where prompts never leave the user's device.
- Adding a local AI assistant to a web app using an OpenAI-style client.
- Developing Chrome extensions that call a language model locally.
- Prototyping browser-based LLM features without running backend inference servers.
Quick start
- 1
Install the package with npm
npm install @mlc-ai/web-llm - 2
Import the engine in your code
import { CreateMLCEngine } from "@mlc-ai/web-llm"; - 3
Create the engine with a model ID (first load downloads the model)
const engine = await CreateMLCEngine("Llama-3.1-8B-Instruct-q4f32_1-MLC", { initProgressCallback });
Things to know
- Requires a browser with WebGPU support.
- The first model load downloads large model files, which can take a long time.
Topics
FAQ
- What is web-llm?
- A TypeScript engine that runs LLM inference entirely in the browser using WebGPU, with an OpenAI-compatible API. WebLLM is an in-browser inference engine for large language models. Inference runs entirely on the client with no server involved, and it uses WebGPU for hardware acceleration. It is distributed as an npm package (@mlc-ai/web-llm) and can also be loaded directly from a CDN.
- Is web-llm free to use? What license does it have?
- web-llm is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is web-llm still maintained?
- Actively maintained. The last commit to web-llm was on Oct 11, 2026.
- What can I use web-llm for?
- Building a privacy-preserving chatbot where prompts never leave the user's device. Adding a local AI assistant to a web app using an OpenAI-style client. Developing Chrome extensions that call a language model locally. Prototyping browser-based LLM features without running backend inference servers.
- How do I install web-llm?
- Install the package with npm: npm install @mlc-ai/web-llm Import the engine in your code: import { CreateMLCEngine } from "@mlc-ai/web-llm"; Create the engine with a model ID (first load downloads the model): const engine = await CreateMLCEngine("Llama-3.1-8B-Instruct-q4f32_1-MLC", { initProgressCallback });
- Where can I get web-llm?
- The source code and installation instructions are on GitHub: https://github.com/mlc-ai/web-llm
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Official training and reference code for RWKV, an RNN-style language model architecture that can also be trained in parallel like a GPT transformer.
A SvelteKit chat interface for LLMs that connects to any OpenAI-compatible API, and the codebase behind HuggingChat.
A community-curated open-source library of prompts for AI chat models, with a website, CSV/Hugging Face datasets, CLI and MCP server integration.
Jan is an open-source desktop app for downloading and running LLMs locally, offering a ChatGPT-like interface with an optional cloud model connection.
A deep learning optimization library for making distributed training and inference of large models easier and more efficient.