DEV Community

Tools Crazy
Tools Crazy

Posted on

Building a Multi-Model AI Image Generator as a Chrome Extension

I shipped AI Photo Genie - a Chrome extension that lets you generate images with FLUX, Z-Image, Seedream, and Nano Banana directly from the toolbar. Here are the architectural decisions that made it work.

AI Photo Genie main interface - Chrome toolbar AI image generator

The Problem

AI image tools require tab-switching. Generate -> download -> upload to editor -> back to work. This takes 2-3 minutes per image. I wanted the full generation loop - prompt -> image -> edit - to happen without leaving the browser.

The Architecture

Chrome Manifest V3 restrictions shaped every decision.

Background Service Worker for API Calls

The extension popup has strict execution limits (and will be killed if it hangs). Long-running AI API calls must be offloaded to the background service worker. The popup sends a message, the service worker calls the API, and replies back via message passing. The key: return true from the message listener to keep the channel open asynchronously.

Unified Model Adapter

FLUX, Z-Image, Seedream, and Nano Banana all have different request formats, authentication patterns, and rate limits. I built a single adapter layer that normalizes them into one interface. The popup never knows which API it is hitting - it just calls generateImage({ model, prompt, width, height }) and gets back a blob URL.

Model selection and prompt controls in AI Photo Genie

Free Credits Without Signup

To eliminate the conversion-killing signup step, I use a device fingerprint tied to the extension install for daily credit tracking. Not bulletproof against determined abusers - but it removes all friction for legitimate users. Install -> generate in under 60 seconds.

PhotoQuill Integration

Generated images open directly in PhotoQuill - our browser-based Photoshop alternative - via chrome.tabs. No file downloads needed between tools. The extension creates a tab, waits for it to load, then sends the image data via message passing.

One-click export to PhotoQuill for advanced browser-based editing

Key Lessons

  1. Service workers die after 30s - break long operations into smaller chunks with keepalive pings
  2. chrome.storage.local is a sync bottleneck - batch reads/writes, do not call on every keystroke
  3. MV3 has no background page - every state you need must be explicitly persisted; do not assume anything survives between events
  4. Different models = different valid aspect ratios - build a model capability manifest early, not as an afterthought

Result

Install -> generate in under 60 seconds, no account required. Free daily credits, no watermarks. Optional paid plans from $4.90/month for heavier usage.

Try it: AI Photo Genie on Chrome Web Store

Questions about Chrome extension architecture, MV3 service worker quirks, or multi-model AI routing? Happy to dig in.

Top comments (0)