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 Smart Writer for a working demo using Chrome AI with automatic fallback to transformers.
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 138+ 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+ only | 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 |
|---|---|---|---|
| Summarizer | Stable | SummarizationModel | 138+ |
| Translator | Stable | TranslationModel | 138+ |
| Prompt API | Stable | LanguageModel | 138+ |
| Writer | Origin trial | — | — |
| Rewriter | Origin trial | — | — |
All three 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+ (or Edge 138+) |
| 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
- Navigate to
chrome://flags/#optimization-guide-on-device-modeland set to Enabled - Navigate to
chrome://flags/#prompt-api-for-gemini-nanoand set to Enabled - For higher-quality summaries:
chrome://flags/#summarization-api-for-gemini-nano→ Enabled with Adaptation - Restart Chrome
- Gemini Nano downloads automatically in the background (~1.5 GB)
- Verify in DevTools Console:
// Check if Summarizer is ready
await Summarizer.availability(); // "readily" = ready, "after-download" = downloading
// Check if Translator is ready
const caps = await Translator.availability({ sourceLanguage: 'en', targetLanguage: 'es' });If availability() returns "after-download", the model is still downloading. Creating a session
with create() requires a user activation (click, tap, or keypress)
to trigger the download.
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