DEV Community
Follow
AI Without a Backend: The Browser's Built-in AI APIs for Web Developers
Chrome now offers built-in AI APIs, utilizing Google's Gemini Nano model directly within the browser. This eliminates the need for API keys, backend proxies, and per-token billing for tasks like summarization or translation. These on-device AI capabilities ensure user data never leaves their machine, enhancing privacy and reducing latency. Initially, these APIs are desktop-only and require a capable machine with a significant initial model download.The APIs are categorized into task-specific tools like Summarizer, Translator, and Writer, and a general-purpose Prompt API for custom or multimodal needs. All APIs follow a consistent lifecycle: feature detection, availability check including model download status, and instance creation. The creation process must be initiated by user gesture and should include progress monitoring for the model download.The Summarizer API allows for condensing text into key points, TL;DRs, teasers, or headlines, with options for format and length. The Prompt API enables multimodal interactions, accepting images and text to generate structured JSON output based on a provided schema. This ensures predictable and parseable results, removing the need for error-prone parsing of unstructured AI responses.These new browser-based AI features should be implemented as progressive enhancements, not core functionalities. A fallback mechanism to server-side processing or graceful degradation is crucial as not all users or devices will support these on-device models. Privacy is a key benefit, allowing developers to highlight local data processing.