A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.chrome.com/docs/ai/summarizer-api below:

Summarize with built-in AI | AI on Chrome

Summarize with built-in AI

Stay organized with collections Save and categorize content based on your preferences.

Published: November 11, 2024, Last updated: July 30, 2025

You can offer your users the ability to distill lengthy articles, complex documents, or even lively chat conversations into concise and insightful summaries.

The Summarizer API can be used to generate different types of summaries in varied lengths and formats, such as sentences, paragraphs, bullet point lists, and more. We believe this API is useful in the following scenarios:

Important: Gemini Nano is generative AI model. Before you build with APIs that use Gemini Nano, you should review the People + AI Guidebook for best practices, methods, and examples for designing with AI. Get started

The Summarizer API is available from Chrome 138 stable.

Before you use this API, acknowledge Google's Generative AI Prohibited Uses Policy.

Run feature detection to see if the browser supports the Summarizer API.

if ('Summarizer' in self) {
  // The Summarizer API is supported.
}
Review the hardware requirements

The following requirements exist for developers and the users who operate features using these APIs in Chrome. Other browsers may have different operating requirements.

The Language Detector and Translator APIs work in Chrome on desktop. These APIs do not work on mobile devices. The Prompt API, Summarizer API, Writer API, and Rewriter API work in Chrome when the following conditions are met:

Gemini Nano's exact size may vary as the browser updates the model. To determine the current size, visit chrome://on-device-internals and go to Model status. Open the listed File path to determine the model size.

Note: If the available storage space falls to less than 10 GB after the download, the model is removed from your device. The model redownloads once the requirements are met. Model download

The Summarizer API uses a model trained to generate high-quality summaries. The API is built into Chrome, and Gemini Nano is the model downloaded the first time a website uses this API.

Important: Gemini Nano is generative AI model. Before you build with APIs that use Gemini Nano, you should review the People + AI Guidebook for best practices, methods, and examples for designing with AI.

To determine if the model is ready to use, call the asynchronous Summarizer.availability() function. If the response to availability() is downloadable, listen for download progress to inform the user of its progress, as it may take time.

const availability = await Summarizer.availability();

To trigger the model download and create the summarizer, check for user activation, then call the asynchronous Summarizer.create() function.

// Proceed to request batch or streaming summarization
const summarizer = await Summarizer.create({
  monitor(m) {
    m.addEventListener('downloadprogress', (e) => {
      console.log(`Downloaded ${e.loaded * 100}%`);
    });
  }
});
API functions

The create() function lets you configure a new summarizer object to your needs. It takes an optional options object with the following parameters:

Once set, the parameters can't be changed. Create a new summarizer object if you need to make modifications to the parameters.

The following table demonstrates the different types of summaries and their corresponding lengths. The lengths represent the maximum possible value, as sometimes, the results can be shorter.

Type Meaning Length "tldr" Summary should be short and to the point, providing a quick overview of the input, suitable for a busy reader. short 1 sentence medium 3 sentences long 5 sentences "teaser" Summary should focus on the most interesting or intriguing parts of the input, designed to draw the reader in to read more. short 1 sentence medium 3 sentences long 5 sentences "key-points" Summary should extract the most important points from the input, presented as a bulleted list. short 3 bullet points medium 5 bullet points long 7 bullet points "headline" Summary should effectively contain the main point of the input in a single sentence, in the format of an article headline. short 12 words medium 17 words long 22 words

For example, you could initialize a summarizer to output a medium length of key points in Markdown.

const options = {
  sharedContext: 'This is a scientific article',
  type: 'key-points',
  format: 'markdown',
  length: 'medium',
  monitor(m) {
    m.addEventListener('downloadprogress', (e) => {
      console.log(`Downloaded ${e.loaded * 100}%`);
    });
  }
};

const availability = await Summarizer.availability();
if (availability === 'unavailable') {
  // The Summarizer API isn't usable.
  return;
}

// Check for user activation before creating the summarizer
if (navigator.userActivation.isActive) {
  const summarizer = await Summarizer.create(options);
}
Run the summarizer

There are two ways to run the summarizer: streaming and batch (non-streaming).

Batch summarization

With batch summarization, the model processes the input as a whole and then produces the output.

To get a batch summary, call the summarize() function. The first argument is the text that you want to summarize. The second, optional argument is an object with a context field. This field lets you add background details that might improve the summarization.

const longText = document.querySelector('article').innerHTML;
const summary = await summarizer.summarize(longText, {
  context: 'This article is intended for a tech-savvy audience.',
});
Tip: Remove any unnecessary data, including HTML markup, when summarizing. For content present on a webpage, you can use the innerText property of an HTML element, as this property represents only the rendered text content of an element and its descendants. Streaming summarization

Streaming summarization offers results in real-time. The output updates continuously as the input is added and adjusted. To get a streaming summary, call summarizeStreaming() instead of summarize().

const longText = document.querySelector('article').innerHTML;
const stream = summarizer.summarizeStreaming(longText, {
  context: 'This article is intended for junior developers.',
});
for await (const chunk of stream) {
  console.log(chunk);
}
Demo

You can try the Summarizer API in the Summarizer API Playground.

Permission Policy, iframes, and Web Workers

By default, the Summarizer API is only available to top-level windows and to their same-origin iframes. Access to the API can be delegated to cross-origin iframes using the Permission Policy allow="" attribute:

<!--
  The hosting site at https://main.example.com can grant a cross-origin iframe
  at https://cross-origin.example.com/ access to the Summarizer API by
  setting the `allow="summarizer"` attribute.
-->
<iframe src="https://cross-origin.example.com/" allow="summarizer"></iframe>

The Summarizer API isn't available in Web Workers for now, due to the complexity of establishing a responsible document for each worker in order to check the permissions policy status.

Standardization effort

We're working to standardize the Summarizer API for cross-browser compatibility.

The Summarizer API and other Writing Assistance APIs have been adopted by the W3C WebML Working Group. We've asked asked Mozilla and WebKit for their standards positions.

We want to see what you're building with the Summarizer API. Share your websites and web applications with us on X, YouTube, and LinkedIn.

For feedback on Chrome's implementation, file a bug report or a feature request.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-30 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-30 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4