Skip to main content
Skip to content
Menu

Gemini Intermediate 3 parts Updated

Build a browser AI feature script

You'll have a working code snippet that runs an AI model locally in your web app without sending data to the cloud.

What you'll make

Local AI Feature Script

  1. initializeLocalAI() — Chrome Prompt API setup and feature detection: what to include
  2. processWithNano() — core text processing with speculative decoding enabled: what to include
  3. fallbackHandler() — what happens when local AI fails or isn't available: what to include
  4. performanceMonitor() — timing and speed measurement utilities: what to include

Paste your complete JavaScript code with comments explaining each optimization decision

The 3 parts

Each part ends with a check you can see.

  1. Test Your Local AI Setup

    Get Chrome Prompt API running on your machine and measure baseline performance

    Done when

    Chrome Prompt API responds to basic prompts with measurable timing data for at least 3 different text processing tasks

  2. Speed Up Your Local Processing

    Implement speculative decoding and other performance optimizations to make local AI feel responsive

    Done when

    Working JavaScript code that reduces inference time by at least 20% compared to baseline, with documented optimization techniques

  3. Handle the Failure Cases

    Build robust fallback handling for when local AI isn't available or produces poor results

    Done when

    Complete script with documented fallback logic that handles at least 4 common failure scenarios gracefully

    Capstone: you put together your Local AI Feature Script.

Where this helps

An elective: a single lesson that sits outside rtwo's job certificates and doesn't count toward one.

About this lesson

What you'll be able to do

  • Run a working script that uses Chrome's built-in Gemini Nano model to process user text without sending data to external servers
  • Configure and test speculative decoding to speed up inference by at least 20% on your actual hardware
  • Identify 3 specific use cases where local AI beats cloud AI for your browser features
  • Have a documented troubleshooting checklist for the 5 most common Chrome Prompt API failures

Who it's for

  • Web developers curious about local AI but unsure about the performance vs privacy tradeoffs
  • Anyone building browser extensions or web apps who wants to keep user data local
  • Developers who can read JavaScript and want to experiment with on-device inference

What it won't cover

  • Training your own models or fine-tuning — you'll use pre-built Gemini Nano
  • Production deployment at scale — this is prototype-level code for learning
  • Mobile browser support — Chrome Prompt API is desktop-only

Skills you'll practise

  • Edge vs server architecture evaluation
  • Local inference performance optimization
  • Chrome extension API integration
  • AI feature fallback design