Bringing AI directly into your browser - no servers, no subscriptions, complete privacy.
This project explores Google Chrome's experimental Prompt API, which brings small AI models directly into the browser. With Gemini Nano running locally on your device, you can perform AI tasks without sending data to external servers, paying subscription fees, or worrying about privacy concerns.
This repository contains three interactive demos showcasing the capabilities of on-device AI in Chrome:
Feed it a theme, mood, and desired length, and watch as it generates:
- ๐ Poems - Creative verses on any topic
- ๐ Short Stories - Narrative fiction with your chosen mood
- ๐ฌ Dialogues - Conversational exchanges between characters
- โจ Custom Content - Any creative writing you can imagine
Instant translation between multiple languages, all running locally:
- ๐ Supports 12+ languages (English, Spanish, French, German, Japanese, Chinese, and more)
- โก Real-time translation without cloud API calls
- ๐ Complete privacy - text never leaves your device
- ๐ No translation API costs
Upload an image and let the browser's AI describe what it sees:
- ๐ผ๏ธ Image analysis and description
- ๐จ Visual content understanding
- ๐ท Object and scene recognition
- ๐ป All processing happens locally on your PC
Traditional AI applications require:
- โ๏ธ Cloud infrastructure and server costs
- ๐ณ Subscription fees or per-use API charges
- ๐ Sending your data to external servers
- ๐ถ Constant internet connectivity
- โฑ๏ธ Network latency for every request
On-device AI changes this:
- โ Runs directly in your browser
- โ Zero server costs
- โ Complete data privacy
- โ Works offline (after initial model download)
- โ Instant responses with no network latency
- โ Perfect for browser extensions and web apps
-
Google Chrome v128 or later (as of July 2025)
- Download from: https://www.google.com/chrome/
-
Enable Experimental Flags
Navigate to these Chrome flags and enable them:
chrome://flags/#prompt-api-for-gemini-nano chrome://flags/#prompt-api-for-gemini-nano-multimodal-input chrome://flags/#optimization-guide-on-device-modelAfter enabling, restart Chrome.
-
First Run Model Download
- The first time you use the API, Chrome will download Gemini Nano (~1-2GB)
- This is a one-time download
- Subsequent uses will be instant
# Navigate to the project folder
cd c:\DevTemp\promptai
# Start a local web server
python -m http.server 8000Then open your browser:
- Creative Writing: http://localhost:8000/app.html
- Translation: http://localhost:8000/translate.html
- Image Analysis: http://localhost:8000/image.html
- Basic Demo: http://localhost:8000/PromptAPISample.html
You can also open the HTML files directly in Chrome:
- Right-click on any
.htmlfile โ "Open with" โ Google Chrome
- Chrome Prompt API - Browser-native AI interface
- Gemini Nano - Google's compact on-device AI model
- Vanilla JavaScript - No frameworks, pure web standards
- HTML5 & CSS3 - Modern, responsive interfaces
-
Availability Check
const availability = await LanguageModel.availability();
-
Session Creation
const session = await LanguageModel.create({ topK: params.defaultTopK, temperature: params.defaultTemperature });
-
Prompt Execution
const response = await session.prompt(userInput);
-
Multimodal Input (for image analysis)
const session = await LanguageModel.create({ multimodal: true }); const response = await session.prompt([text, imageBlob]);
- Download Progress Monitoring - Track model download status
- Session Management - Efficient resource handling
- Error Handling - Graceful fallbacks for unsupported systems
- Responsive UI - Works on desktop and tablet devices
- Real-time Generation - Instant AI responses
promptai/
โ
โโโ app.html # Creative Writing Assistant
โโโ translate.html # Translation Assistant
โโโ image.html # Vision/Image Analysis
โโโ PromptAPISample.html # Basic API test demo
โโโ code.html # Demo screenshots gallery
โ
โโโ images/ # Screenshots and assets
โ โโโ 1.png # Creative writing demo
โ โโโ 2.png # Translation demo
โ โโโ 3.png # Image analysis demo
โ โโโ joke-visual.png # Sample test image
โ
โโโ cgi-bin/ # Web server utilities
โโโ web.py # Simple Python CGI script
โโโ web.md # Server instructions
- 4 content types (poem, story, dialogue, custom)
- Mood selection (happy, sad, mysterious, humorous, etc.)
- Length control (short, medium, long)
- Theme-based generation
- Beautiful gradient UI with animations
- 12+ language support
- Bidirectional translation
- Swap source/target languages
- Real-time translation
- Clean, intuitive interface
- Character count display
- Drag-and-drop image upload
- File browser support
- Detailed image analysis
- Custom prompt support
- Example prompts included
- Sample images for testing
This is just the beginning. The Prompt API opens doors to:
- ๐ Browser Extensions - AI-powered tools without backend infrastructure
- ๐ Content Tools - Writing assistants, grammar checkers, summarizers
- ๐จ Creative Apps - Story generators, code helpers, brainstorming tools
- ๐ Privacy-First Apps - Sensitive data processing without cloud exposure
- ๐ Offline-First Apps - AI that works without internet
- ๐ Data Analysis - Local processing of sensitive information
- Model Size - Gemini Nano is compact; complex tasks may need larger models like ChatGPT or Claude
- Browser Support - Currently Chrome 128+ only (Edge Canary has experimental support)
- Experimental Status - API may change before stable release
- Hardware Requirements - Works best with modern CPUs and GPUs
- Initial Download - ~1-2GB model download on first use
| Browser | Status | Model |
|---|---|---|
| Chrome 128+ | โ Available (experimental) | Gemini Nano |
| Edge Canary | ๐งช Testing | Phi-4 |
| Firefox | โ Not yet | - |
| Safari | โ Not yet | - |
- Chrome Prompt API Documentation
- Web Machine Learning Community Group
- Gemini Nano Information
- Built-in AI Early Preview Program
Feel free to:
- ๐ Report bugs or issues
- ๐ก Suggest new demo ideas
- ๐ง Submit pull requests
- ๐ Improve documentation
- ๐ Share your experience with the Prompt API
The HTML, CSS, and JavaScript for these demos were generated with assistance from Claude AI, following the official Prompt API documentation from the Web Machine Learning Community Group.
This project is open source and available under the MIT License.
Created as an exploration of Chrome's experimental Prompt API and on-device AI capabilities.
Blog Post: AI is now inside your browser โ Prompt API
Date: July 17, 2025
I'd love to hear about your experience with these demos! If you try them out, please share:
- What worked well
- What could be improved
- Ideas for new demos
- Your thoughts on on-device AI
โญ If you find this project interesting, please star it on GitHub!
Built with curiosity, powered by on-device AI ๐
