Introduction
Chrome’s Built-In AI APIs allow web applications to perform selected AI tasks using models managed by the browser.
Unlike traditional cloud-based AI integrations, developers do not need to deploy or operate separate model infrastructure for these workloads.
This guide introduces the major Built-In AI APIs and provides small examples of each API. Complete runnable examples are linked separately.
Getting Started
Chrome’s Built-In AI APIs are at different stages of availability. The Language Detector, Translator, and Summarizer APIs are available in stable Chrome on supported desktop devices, while other APIs have different availability and testing requirements.
Enabling Experimental APIs for Local Testing
The required setup depends on the API and Chrome version being tested.
During local testing with Chrome 149, the following flags were enabled:
chrome://flags/#optimization-guide-on-device-model
chrome://flags/#prompt-api-for-gemini-nano
chrome://flags/#prompt-api-for-gemini-nano-multimodal-input
chrome://flags/#writer-api-for-gemini-nano
chrome://flags/#proofreader-api-for-gemini-nano
Enter fullscreen mode Exit fullscreen mode
After changing Chrome flags, fully relaunch the browser.
Note: Chrome’s Built-In AI APIs are evolving. Check the current Chrome documentation for the release status and setup requirements of the specific API you are using rather than assuming that every API requires the same configuration.
Language Detector API
The Language Detector API identifies the language of a given text.
Use Cases
- Dynamic localization
- Query routing
- Analytics
- Content classification
Example
const detector = await LanguageDetector.create();
const result = await detector.detect("Bonjour tout le monde");
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Language Detector API on GitHub Gist
Translator API
The Translator API translates text between supported languages.
Use Cases
- Localization
- User-generated content translation
- Multilingual applications
Example
const translator = await Translator.create({
sourceLanguage: "en",
targetLanguage: "ar"
});
const result = await translator.translate("Hello, world!");
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Translator API on GitHub Gist
Summarizer API
The Summarizer API generates summaries of text.
Use Cases
- Release notes
- Article digests
- Document summaries
- Knowledge management
Example
const summarizer = await Summarizer.create({
type: "key-points",
length: "short"
});
const result = await summarizer.summarize(longText);
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Summarizer API on GitHub Gist
Prompt API
The Prompt API provides access to Gemini Nano for general-purpose inference.
Use Cases
- Metadata extraction
- Classification
- Structured output generation
- Lightweight reasoning
Example
const session = await LanguageModel.create();
const result = await session.prompt(
"Extract structured data from this text."
);
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Prompt API on GitHub Gist
Writer API
The Writer API generates new content based on an input prompt.
Use Cases
- Email drafts
- Documentation
- Support responses
Example
const writer = await Writer.create({
tone: "neutral",
length: "short"
});
const result = await writer.write(
"Write a short introduction to browser-based AI."
);
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Writer API on GitHub Gist
Rewriter API
The Rewriter API transforms existing content.
Use Cases
- Incident reports
- User reviews
- Internal communications
Example
const rewriter = await Rewriter.create({
tone: "more-formal"
});
const result = await rewriter.rewrite(
"We fixed the issue and everything looks good now."
);
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Rewriter API on GitHub Gist
Streaming UI example: Rewriter Streaming on GitHub Gist
Proofreader API
The Proofreader API checks text for writing errors and provides suggested corrections.
Use Cases
- Documentation review
- Content publishing
- User-generated content
Example
const proofreader = await Proofreader.create();
const result = await proofreader.proofread(
"This sentence have a grammatical error."
);
console.log(result);
Enter fullscreen mode Exit fullscreen mode
Complete runnable example: Proofreader API on GitHub Gist
Security Considerations
On-device inference changes where computation occurs, but it does not eliminate application security risks.
AI-generated output should be treated as untrusted data and validated using the same rigor applied to other untrusted input.
Do not execute generated code or render generated HTML without appropriate validation and sanitization. AI-generated output should also not be trusted to make security-sensitive decisions such as authorization.
Final Thoughts
Chrome’s Built-In AI APIs are a practical way to experiment with browser-managed inference.
Task-specific APIs such as translation, language detection, and summarization are particularly well suited to browser-managed inference. For workloads that require broader capabilities or consistent availability across browsers and devices, cloud-hosted models remain an important option, leading to a hybrid approach where local and remote inference coexist.
The most practical architecture is often a hybrid one: use browser-managed AI when the required capability is available, fall back to cloud services when broader capabilities are needed, and use deterministic logic when AI is unnecessary.
답글 남기기