---
title: API updates on Chrome on-device AI (Apr 2025)
url: https://calvin.my/posts/api-updates-on-chrome-on-device-ai-apr-2025
published: 2025-05-07
updated: 2026-09-17
category: AI
tags:
- Gemini Nano
- gemini
- Chrome
- webAI
summary: Chrome Canary 136 and later updates its on-device AI APIs by renaming package namespaces and changing streaming responses to deliver only newly generated tokens. Setup is simplified because one former Chrome flag is no longer required, while the Gemini Nano prompt API flag remains necessary. The revised sample emphasizes checking model availability, creating a configured language-model session, appending streamed output, and cleaning up sessions afterward.
---

# API updates on Chrome on-device AI (Apr 2025)

This article is an update for the previous articles below:

1. [https://calvin.my/posts/on-device-generative-ai-with-gemini-nano](../posts/on-device-generative-ai-with-gemini-nano)
2. [https://calvin.my/posts/on-device-generative-ai-with-gemini-nano-part-2](../posts/on-device-generative-ai-with-gemini-nano-part-2)
3. [https://calvin.my/posts/api-updates-on-chrome-on-device-ai](../posts/api-updates-on-chrome-on-device-ai)
4. [https://calvin.my/posts/api-updates-on-chrome-on-device-ai-nov-2024](../posts/api-updates-on-chrome-on-device-ai-nov-2024)

* * *

## Updates in April 2025

1. From Chrome Canary 136+, the package name is renamed from `self.ai.*` to `self.*`

   ```javascript
   await LanguageModel.availability();
   await Summarizer.availability();
   await Writer.availability();
   await Rewriter.availability();
   await LanguageDetector.availability();
   await Translator.availability();
   
   await LanguageModel.create();
   await Summarizer.create();
   await Writer.create();
   await Rewriter.create();
   await LanguageDetector.create();
   await Translator.create();
   ```

2. Streaming output changes. Previously, the chunk included everything from index 0 to the latest tokens. The updated behavior returns only the new tokens, which matches the behavior of the mainstream Generative AI streaming API.

   ```javascript
   // New
   for await (const chunk of stream) {
       this.outputTarget.textContent += chunk;
   }

   // Old
   for await (const chunk of stream) {
       this.outputTarget.textContent = chunk;
   }
   ```

3. The optimization-guide-on-device-model flag in Google Chrome is no longer a necessary step in the setup. The prompt-api-for-gemini-nano is needed.

   ```markup
   chrome://flags/#prompt-api-for-gemini-nano
   ```

4. Updated sample code:

   ```javascript
   async askAi(prompt) {
           const availability = await LanguageModel.availability();

           if (availability === "available") {
               const capabilities = await LanguageModel.params();
               const systemPrompt = "You are a helpful assistant.";
               const session = await ai.languageModel.create({
                   systemPrompt: systemPrompt,
                   temperature: 0,
                   topK: capabilities.defaultTopK
               });

               const stream = session.promptStreaming(prompt);
               for await (const chunk of stream) {
                   this.outputTarget.textContent += chunk;
               }
               session.destroy();
           } else {
               this.outputTarget.textContent = "Error! On-device AI is not available on your browser."
           }
   }
   ```
