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, andLanguageModelfrom@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/corenpm install @localmode/chrome-ai @localmode/coreyarn add @localmode/chrome-ai @localmode/corebun add @localmode/chrome-ai @localmode/coreQuick 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
| Aspect | Chrome AI | Transformers.js | WebLLM |
|---|---|---|---|
| First inference | Instant | After model download (50MB–2GB) | After model download (1–4GB) |
| Bundle size | 0 bytes | ~2MB (WASM runtime) | ~1MB |
| Model download | None | Required | Required |
| Browser support | Chrome 138+ (Summarizer/Translator); Chrome 148+ (Prompt API) | All browsers | Chrome/Edge (WebGPU) |
| Offline | Yes (native) | Yes (after cache) | Yes (after cache) |
| Model quality | Good (Gemini Nano) | Varies by model | High (larger models) |
Available APIs
| API | Status | LocalMode Interface | Chrome Version (web pages) |
|---|---|---|---|
| Summarizer | Stable | SummarizationModel | 138+ |
| Translator | Stable | TranslationModel | 138+ |
| Language Detector | Stable | — | 138+ |
| Prompt API | Stable | LanguageModel | 148+ |
| Writer | Developer trial | — | — |
| Rewriter | Developer trial | — | — |
| Proofreader | Developer 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.
| Requirement | Detail |
|---|---|
| Browser | Chrome 138+ for Summarizer / Translator; Chrome 148+ for the Prompt API |
| OS | Windows 10+, macOS 13+ (Ventura), Linux, ChromeOS (Chromebook Plus) |
| Disk space | 22 GB free on the volume containing your Chrome profile |
| Hardware | GPU 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
Language Model
Generate text with Gemini Nano via the Prompt API
Summarization
Summarize text with configurable type, format, and length
Translation
Translate text between languages instantly
Fallback Patterns
Graceful degradation for non-Chrome browsers
Composed Blocks
| Block | Description | Links |
|---|---|---|
| Write | Chrome AI writing assistance with automatic Transformers.js fallback | Live · Install: npx shadcn add @localmode/ui/blocks/writing-tools/write |
| Translate | Chrome AI translation with automatic Transformers.js fallback | Live · Install: npx shadcn add @localmode/ui/blocks/writing-tools/translate |
| Summarize | Chrome AI summarization with automatic Transformers.js fallback | Live · Install: npx shadcn add @localmode/ui/blocks/writing-tools/summarize |
| Complete | Transformers.js ModernBERT fill-mask completion | Live · Install: npx shadcn add @localmode/ui/blocks/writing-tools/complete |