This project was inspired by lightning-joyce/chromeai.
Visit the page alexcheng1982.github.io/chromeai/.
promptStreaming
is used for streaming output. During testing, I found out that prompt
often gave incomplete results.
Latest version of Google Chrome (127+) or any compatible Chromium-based browser.
Tested Chrome versions:
129.0.6640.0
- Install Chrome Canary: Ensure you have version 129. Download Chrome Canary.
- Enable Prompt API: Open
chrome://flags/#prompt-api-for-gemini-nano
, set it to "Enabled". - Enable Optimization Guide: Open
chrome://flags/#optimization-guide-on-device-model
, set it to "Enabled BypassPerfRequirement". Restart the browser. - Download Model: Go to
chrome://components/
, find Optimization Guide On Device Model, ensure it’s fully downloaded. If the version is "0.0.0.0", click "Check for update". - Verify Setup: Open a webpage, press F12, and check
window.ai
in the console.
Test Code:
const model = await window.ai.createTextSession();
await model.prompt("Who are you?");
- When message history is enabled, the model may not function properly.