Published: May 20, 2025
Explainer | Web | Extensions | Chrome Status | Intent |
---|---|---|---|---|
GitHub | View | Intent to Experiment |
With the Prompt API, you can send natural language requests to Gemini Nano in the browser.
The Prompt API is available for Chrome Extensions. Web developers can use the exploratory API in Chrome Canary, by joining the Early Preview Program. This API will soon be available in an origin trial.
There are many ways you can use the Prompt API. In a web application or website, you can create:
- AI-powered search: Answer questions based on the content of a web page.
- Personalized news feeds: Build a feed that dynamically classifies articles with categories and allow for users to filter for that content.
In Chrome Extensions, you can build:
- Calendar events. Develop a Chrome Extension that automatically extracts event details from web pages, so users can create calendar entries in just a few steps.
- Contact extraction. Build an extension that extracts contact information from websites, making it easier for users to contact a business or add details to their list of contacts.
These are just a few possibilities, but we're excited to see what you create.
Use the Prompt API
There are two main functions available to you in the LanguageModel
namespace:
availability()
to check what the model is capable of and if it's available.create()
to start a language model session.
Model download
The Prompt API uses the Gemini Nano model in Chrome. While the API is built into Chrome, the model is downloaded separately the first time an extension uses the API.
To determine if the model is ready to use, call the asynchronous
LanguageModel.availability()
function. This should return one of the
following responses:
"unavailable"
means that the browser does not support the requested options, or does not support prompting a language model at all."downloadable"
means that the browser supports the requested options, but it will have to download something (for example, the language model itself, or a fine-tuning) before it can create a session using those options."downloading"
means that the browser supports the requested options, but will need to finish an ongoing download operation before it can create a session using those options."available"
means that the browser supports the requested options without requiring any new downloads.
If the response to availability()
is 'downloadable'
, listen for download
progress and inform the user, in case the download takes time.
const session = await LanguageModel.create({
monitor(m) {
m.addEventListener("downloadprogress", (e) => {
console.log(`Downloaded ${e.loaded} of ${e.total} bytes.`);
});
},
});
Multimodal capabilities
The Prompt API supports audio and image inputs from Chrome 138 Canary, for local experimentation. The API returns a text output.
With these capabilities, you could:
- Allow users to transcribe audio messages sent in a chat application.
- Describe an image uploaded to your website for use in a caption or alt text.
Your feedback helps inform the future of this API and improvements to Gemini Nano. It may even result in dedicated task APIs (such as APIs for audio transcription or image description), ensuring we meet your needs and the needs of your users.
Participate and share feedback
Your input can directly impact how we build and implement future versions of this API and all built-in AI APIs.
- Join the early preview program.
- For feedback on Chrome's implementation, file a bug report or a feature request.
- Share your feedback on the API shape by commenting on an existing Issue or by opening a new one in the Prompt API GitHub repository.
- Participate in the standards effort by joining the Web Incubator Community Group.