LocalMode
Chrome AI

Overview

Zero-download, instant AI inference via Chrome built-in Gemini Nano

@localmode/chrome-ai

Zero-download, instant AI inference via Chrome's built-in Gemini Nano model. No model downloads, no bundle size impact, no API keys — the model ships with the browser.

See it in action

Try the Writing Tools blocks — live, installable apps using Chrome AI with automatic fallback to Transformers.js for writing, translation, summarization, and completion.

Features

  • Zero model downloads — Gemini Nano ships with Chrome
  • Zero bundle size impact — browser-native APIs
  • Instant inference — no model loading delay
  • Implements SummarizationModel, TranslationModel, and LanguageModel from @localmode/core
  • Feature detection utilities for graceful fallback

The LanguageModel implementation wraps Chrome 148+ window.LanguageModel (the Prompt API) so generateText(), streamText(), generateObject(), and the useGenerateText() / useStreamText() / useModelWarmup() React hooks work on Gemini Nano with zero changes from any other provider.

Installation

pnpm add @localmode/chrome-ai @localmode/core
npm install @localmode/chrome-ai @localmode/core
yarn add @localmode/chrome-ai @localmode/core
bun add @localmode/chrome-ai @localmode/core

Quick Start

import { summarize } from '@localmode/core';
import { chromeAI } from '@localmode/chrome-ai';

const { summary } = await summarize({
  model: chromeAI.summarizer(),
  text: 'Long article text...',
});

console.log(summary);

Comparison

AspectChrome AITransformers.jsWebLLM
First inferenceInstantAfter model download (50MB–2GB)After model download (1–4GB)
Bundle size0 bytes~2MB (WASM runtime)~1MB
Model downloadNoneRequiredRequired
Browser supportChrome 138+ (Summarizer/Translator); Chrome 148+ (Prompt API)All browsersChrome/Edge (WebGPU)
OfflineYes (native)Yes (after cache)Yes (after cache)
Model qualityGood (Gemini Nano)Varies by modelHigh (larger models)

Available APIs

APIStatusLocalMode InterfaceChrome Version (web pages)
SummarizerStableSummarizationModel138+
TranslatorStableTranslationModel138+
Language DetectorStable138+
Prompt APIStableLanguageModel148+
WriterDeveloper trial
RewriterDeveloper trial
ProofreaderDeveloper trial

The Prompt API ships later than the rest

Summarizer and Translator have been stable for web pages since Chrome 138. The Prompt API — the one backing chromeAI.languageModel() — only shipped for web pages in Chrome 148; Chrome 138 shipped it for Chrome Extensions, which is a different surface. Two consequences: chromeAI.summarizer() and chromeAI.translator() reach far more users than chromeAI.languageModel(), and temperature / topK remain gated behind the "Prompt API sampling parameters" origin trial on web pages even on Chrome 148+.

All stable APIs (Summarizer, Translator, Prompt) are supported by @localmode/chrome-ai. The Prompt API exposes Gemini Nano text generation via chromeAI.languageModel() — see the Language Model guide.

Requirements

Chrome AI is only available on desktop browsers. Mobile (Android/iOS) and Incognito mode are not supported.

RequirementDetail
BrowserChrome 138+ for Summarizer / Translator; Chrome 148+ for the Prompt API
OSWindows 10+, macOS 13+ (Ventura), Linux, ChromeOS (Chromebook Plus)
Disk space22 GB free on the volume containing your Chrome profile
HardwareGPU with >4 GB VRAM, or CPU with 16 GB+ RAM and 4+ cores

Enabling Chrome AI

On a supported Chrome stable build, no flags are required — these APIs ship on by default. What you do need is for Chrome to have downloaded Gemini Nano, which happens once, browser-wide, on first use.

Verify the state in the DevTools console:

// Does the API exist at all?
'LanguageModel' in self; // Prompt API   — Chrome 148+
'Summarizer' in self; //    Summarizer   — Chrome 138+
'Translator' in self; //    Translator   — Chrome 138+

// Is the model ready? Returns one of:
//   'available'    — ready to use right now
//   'downloadable' — API present, model not fetched yet
//   'downloading'  — fetch in progress
//   'unavailable'  — this device/build cannot run it
await LanguageModel.availability();
await Summarizer.availability();
await Translator.availability({ sourceLanguage: 'en', targetLanguage: 'es' });

If availability() returns 'downloadable' or 'downloading', the model is not on disk yet. @localmode/chrome-ai refuses to start that download implicitly — it throws chrome-ai-download-required. Opt in with providerOptions: { chromeAI: { allowDownload: true } }, and call it from a user activation (click, tap, or keypress), which Chrome requires to trigger the ~1.5 GB fetch.

If the API is missing on a recent Chrome

On older builds the Prompt API sat behind chrome://flags/#prompt-api-for-gemini-nano, with the model behind chrome://flags/#optimization-guide-on-device-model. Those flags are no longer needed on stable and are being retired — if you enabled them long ago, note that they also mask the real availability story from your users, most of whom will not have set them. Test with a clean profile before assuming a feature works.

Provider Factory

import { createChromeAI, chromeAI } from '@localmode/chrome-ai';

// Default instance
const summarizer = chromeAI.summarizer();
const translator = chromeAI.translator({ targetLanguage: 'de' });
const llm = chromeAI.languageModel({ systemPrompt: 'You are concise.' });

// Custom instance
const provider = createChromeAI();
const customSummarizer = provider.summarizer({ type: 'key-points', format: 'markdown' });

Feature Detection

import {
  isChromeAISupported,
  isPromptAPISupported,
  isSummarizerAPISupported,
  isTranslatorAPISupported,
} from '@localmode/chrome-ai';

if (isChromeAISupported()) {
  console.log('Chrome AI is available');
}

if (isPromptAPISupported()) {
  console.log('Prompt API (LanguageModel) is ready');
}

if (isSummarizerAPISupported()) {
  console.log('Summarizer API is ready');
}

Next Steps

Composed Blocks

BlockDescriptionLinks
WriteChrome AI writing assistance with automatic Transformers.js fallbackLive · Install: npx shadcn add @localmode/ui/blocks/writing-tools/write
TranslateChrome AI translation with automatic Transformers.js fallbackLive · Install: npx shadcn add @localmode/ui/blocks/writing-tools/translate
SummarizeChrome AI summarization with automatic Transformers.js fallbackLive · Install: npx shadcn add @localmode/ui/blocks/writing-tools/summarize
CompleteTransformers.js ModernBERT fill-mask completionLive · Install: npx shadcn add @localmode/ui/blocks/writing-tools/complete

On this page