In-Browser AI: An Engineering Guide

In-Browser AI: An Engineering Guide

WebGPU reached all four major browsers, with platform gaps, and the browser became an inference runtime. Which tasks belong on the client, the three delivery routes, and the decisions behind shipping.

In-browser AI became a practical engineering option in late 2025, when WebGPU became officially supported in Chrome, Edge, Firefox, and Safari, with platform gaps (it is not Baseline as of November 2026): classification, embeddings, transcription, and short-form generation can now run on the user's device with no per-call inference cost. This guide gives you the sweet-spot task profile, an honest comparison of the three delivery routes, and the decision set a feature owner works through before shipping client-side inference.

The browser became an inference runtime

For most of the web's history, AI features meant a server round-trip. The model lived behind an API, every call carried latency and a bill, and the user's content traveled to someone else's machine to be processed. The browser was a rendering surface, not a compute platform.

That changed structurally, not gradually. WebGPU — the compute API that lets a web page run serious parallel workloads on the device's GPU — is officially supported in Chrome, Edge, Firefox, and Safari, with platform conditions, per a web.dev announcement published November 25, 2025. Chrome, Edge, and other Chromium-based browsers have it on Windows (with Direct3D 12), macOS, and ChromeOS starting with Chrome and Edge 113, and Chrome 121 added Android for devices running at least Android 12 with Qualcomm/ARM GPUs. Firefox 141 covered Windows, and Firefox 145 added macOS Tahoe 26 on ARM64 machines. Safari brought it to macOS Tahoe 26, iOS 26, iPadOS 26, and visionOS 26, so Apple devices that cannot run those releases do not get it. The honest gaps that announcement lists: Chromium support for Linux and expanded support for existing platforms are in progress, and Firefox support for Linux, Android, and Intel-based Macs is in progress. WebGPU is also not Baseline: web-features 3.46.0 marks it as limited availability, with no Firefox or Firefox for Android support entry (as of November 2026). Broad support across the four major browsers is now a reasonable planning assumption, and the platform gaps are what you engineer around rather than the other way about.

What this unlocks for the engineer is concrete. Work that previously demanded a server — classifying a piece of text, computing an embedding, transcribing audio, drafting a short reply — can execute inside the page, on hardware the user already owns. There is no per-request inference bill, no queue in front of a shared endpoint, and no network between the user's keystroke and the model's answer.

The counterweight belongs in the same paragraph. The browser is a constrained runtime: model size is capped by what a page can reasonably deliver and what a device can hold in memory, battery and thermals are real, and heavy multi-step reasoning stays on the server. The cost story is structural, not magical — client inference removes the per-call fee and adds model-asset delivery, device variance, and a maintenance obligation. Where that balance lands is a per-feature calculation, and this topic exists to make that calculation disciplined.

The sweet-spot task profile

The first decision is not which model or which runtime. It is whether the task belongs on the client at all, and four properties predict the answer.

The first is high call frequency. Work that fires per keystroke, per list item, or per scroll position is ruinous as API calls and free once the model is local. The second is low task complexity: classification, extraction, similarity, and short summarization are small-model territory; multi-step reasoning is not. The third is latency sensitivity — when the round-trip itself is the UX problem, as in live autocomplete or on-the-fly transcription, locality is the feature. The fourth is privacy sensitivity: content a user would hesitate to send anywhere — drafts, private notes, microphone audio — becomes serviceable the moment processing stays on the device.

A feature that scores high on two or more of these properties is a genuine candidate. The shapes that fit are recognizable: local writing assistance and autocomplete, content classification and moderation pre-filters, semantic search over what the user is currently working on, live transcription of a meeting the user would not upload, image cleanup with instant feedback.

The arithmetic behind the frequency property is worth seeing once. A moderation pre-filter that classifies every comment as it is typed might fire thousands of times for a single active user. As API calls, that is a real line item and a real latency tax on every keystroke; as local inference against a model measured in tens of megabytes, the marginal cost of each call is effectively zero once the model is cached. The same arithmetic runs in reverse for a feature used only occasionally — the download and cache footprint cannot be amortized, and the server path wins. Frequency is not a detail; it is often the whole business case.

The anti-profile deserves equal clarity. Long-context synthesis, quality-critical generation, agentic multi-step work, and any task where a wrong answer costs more than a round-trip belong on the server, where large models live. A task that fails the profile does not become viable because the runtime demo is impressive — the profile is the gate, and the rest of this guide assumes you have a task that passes it.

Three delivery routes

Once a task qualifies, there are three ways to get inference in front of it. They differ in who ships the model, what the page pays, and how far the result reaches.

The first route is browser built-in AI APIs. The browser itself downloads and manages a small model on the device, and pages call it through task-scoped APIs — summarize, translate, detect language, prompt. In Chrome, per its model-management documentation (published October 21, 2025), the model is downloaded on demand, so Chrome can fetch the correct model for the user's hardware, and only if the device meets the hardware requirements; Chrome's getting-started documentation also says its built-in models aren't available on mobile devices. Every update is a full new model download, and the model can be deleted again — when free disk space drops below a threshold, when an enterprise policy disables the feature, or when the user hasn't met other eligibility criteria for 30 days. The economics are attractive because the page ships no weights at all. The honesty requirement is equally large: as of November 2026 this is a Chromium-led, single-engine reality, and availability differs API by API — Chrome's status page puts some APIs in Chrome Stable, others in origin trials open to all developers or in developer trials, and some only in the Early Preview Program — and the landscape moves fast. Built-ins are a progressive enhancement on top of a route you control, never the cross-browser foundation.

The second route is library-run open models: an inference library executes a model your page delivers, on WebGPU or WebAssembly as your capability probe and the library allow — Transformers.js, for example, runs a model on WebGPU when you set device: 'webgpu' while loading it. This is the route you control end to end. For task-shaped models — embeddings, classification, speech, vision — Transformers.js v4 is the load-bearing worked example. Hugging Face announced it on February 9, 2026 (the stable 4.0.0 release reached npm on March 30, 2026); its new WebGPU runtime is completely rewritten in C++, and Hugging Face says it worked closely with the ONNX Runtime team to thoroughly test that runtime across its roughly 200 supported model architectures and many new v4-exclusive ones. It runs a wide catalog of open models directly in the page. For chat-shaped work, WebLLM exposes an API its README describes as fully compatible with the OpenAI API, with function calling still marked work in progress (as of November 2026), over models running entirely in the browser. In the WebLLM paper's tests — 4-bit quantized models, WebLLM v0.2.75 in Chrome Canary 133, on one Apple MacBook Pro M3 Max — WebLLM retained up to about 80% of the decoding throughput of native MLC-LLM on the same device (figures as of the paper's publication; re-verify against current releases before relying on them).

The third route is server inference — and it is a route, not a defeat. It is the fallback for devices that fail the capability probe and the primary path for every task the sweet-spot profile excludes. How that server path is hosted, from managed inference APIs to self-run GPU infrastructure, is a hosting decision with its own literature; this topic stops at the fact that the path exists and must be designed for.

RouteWho ships the modelCost to the pageReachTask rangeOver-commitment failure
Built-in browser APIsThe browser, on demand (in desktop Chrome, only on eligible hardware, re-downloaded in full on updates)None — no weights shippedSingle-engine (Chromium)Task APIs plus a small prompt surfaceFeature exists only in Chromium-engine browsers that ship that API
Library-run open modelsYour page, via hub downloadAsset delivery, storage, memoryEverywhere the probe passesAny open model the device can holdWeight and maintenance cost outgrow feature value
Server inferenceYour infrastructure or providerPer-call cost and latencyEvery device with a networkAnything, including heavy reasoningPaying round-trips for work a device does free

Route capabilities and availability above are as of November 2026, per the vendor documentation linked in this section — re-verify before committing an architecture to them.

The decisions the feature owner makes

Shipping client-side inference is a chain of owned decisions, and each has enough depth that this topic gives it a dedicated treatment. The map, in the order the decisions usually arrive:

Model fit comes first: task-specific model versus small instruct LLM, with size, quantization, and licensing as the levers — and the deliberate discipline of picking the smallest model that does the job. Device fit follows: a capability probe that inspects WebGPU and WASM support before any download begins, feeding a written degradation ladder that decides which devices get which experience. Loading and memory are the physical constraints: the model can outweigh everything else your page ships, so delivery, caching, versioning, and the resident-memory budget are engineering artifacts rather than afterthoughts. Inference UX makes the wait honest — download consent, streaming output, and a page that never freezes. Then come the surfaces: the built-in API route as an accelerating rung, embeddings as the quiet workhorse for semantic features, and speech and vision tasks, where raw audio and images can stay on the device. Hybrid routing binds client and server paths behind one interface, privacy turns the on-device claim into an engineered, documented property, and evaluation proves the small model is good enough for your task and keeps it proven as models churn. This topic closes with the honest limits — the cases where the right answer is not to run AI in the browser at all.

Two of those decisions deserve a sentence more here, because they are where demos can diverge from products. Loading is first-run economics: the user's first experience of the feature is a download, and whether that download is consented, resumable, cached correctly, and never repeated determines whether the feature reads as substantial or broken. Evaluation is the other: a small model that looks fluent in a demo can fail your actual task in ways a task-specific evaluation set — versioned in the repo, re-run on every model or prompt change — can surface before users do. A team that skips either step can end up revisiting it after launch, under worse conditions.

The boundaries of this topic are equally deliberate. Using coding agents to build software is a different craft with its own literature — this topic is about AI as a shipped feature, not AI as a development tool. The server side's hosting economics belong to the hosting literature. WebGPU driving 3D graphics is a different workload on the same API, covered in the expressive-web writing. And organization-level AI strategy — model procurement, governance, platform teams — is decision-maker territory above the individual engineer's PR, which is where this topic deliberately lives.

What in-browser AI cannot do

A guide that only sells the upside would be doing you a disservice, so the limits get their own section.

The quality ceiling is real. In practice, quantized chat-shaped models in the single-digit billions of parameters are a practical target for in-browser chat on consumer hardware — a judgment from what fits in page delivery and device memory, not a documented hard limit (the WebLLM paper's own tests used 4-bit models of 3.8 and 8 billion parameters on a single Apple MacBook Pro M3 Max). No amount of fallback design turns a 3-billion-parameter quantized model into a frontier model, and a feature whose quality bar requires the latter should not pretend otherwise.

Device inequality is a product decision, not a footnote. The feature that flies on your development workstation can degrade — or vanish — on lower-end phones in your audience, and the tiers can track device price. Shipping client AI means consciously owning a tiered experience, measuring which share of real users lands on which tier, and being willing to conclude that a given feature should stay server-side for equity's sake.

The maintenance ledger accrues quietly. Models are updated, quantization recipes evolve, runtimes ship breaking changes, and browser support moves fast — which is why every capability claim within this topic carries a source and an as-of date, and why the team that ships a client-AI feature inherits the obligation to re-verify those claims on a schedule.

Finally, on-device is a privacy property, not a privacy guarantee. The model download itself signals feature usage, telemetry and error reports can leak content, and a silent server fallback converts the privacy story to false without touching the happy path. The property is real and valuable — it has to be engineered and disclosed deliberately, and this topic treats that engineering as part of the craft rather than a marketing afterthought.

The browser has earned its place as an inference runtime. The craft is knowing which features that place is for — and building the ladder, the budget, and the evidence before the feature meets its first real device.

Project Inquiry