<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus" -->

---
title: Smart photo organization through privacy-first, on-device AI
description: A walkthrough of building a privacy-first photo organization PWA using Firebase AI Logic SDK with hybrid inference: on-device Gemini Nano runs in-browser when...
canonical: https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Smart photo organization through privacy-first, on-device AI | daily.dev
og:description: A walkthrough of building a privacy-first photo organization PWA using Firebase AI Logic SDK with hybrid inference: on-device Gemini Nano runs in-browser when...
og:url: https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus
og:image: https://api.daily.dev/og/posts/56VZTZSUS.png
og:image:alt: Smart photo organization through privacy-first, on-device AI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart photo organization through privacy-first, on-device AI

**[Firebase](https://daily.dev/sources/firebase-blog)** · 10 min read · 0 upvotes · 0 comments

## Summary

A walkthrough of building a privacy-first photo organization PWA using Firebase AI Logic SDK with hybrid inference: on-device Gemini Nano runs in-browser when available, falling back transparently to a cloud model (gemini-2.5-flash-lite) with user consent when it's not. Covers multimodal prompting, structured JSON output schemas for metadata and sorting, a streaming-like UX pattern for per-image results, and exporting AI-generated tags into image EXIF/XMP metadata for portability.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2025/10/privacy-first-on-device-ai>

## Questions this post answers

### How do I set up hybrid AI inference with Firebase AI Logic so it uses Gemini Nano on-device but falls back to a cloud model?

Set the mode to InferenceMode.PREFER_ON_DEVICE when calling getGenerativeModel, and define both inCloudParams (e.g. specifying gemini-2.5-flash-lite with a responseSchema) and onDeviceParams (with promptOptions.responseConstraint and createOptions for expected inputs/outputs). The Firebase AI Logic SDK then automatically checks if Gemini Nano is available in the browser and falls back to the cloud model when it isn't.

_daily.dev surfaces practical Firebase AI Logic patterns for developers building hybrid on-device and cloud AI features._

### How can I force a model in Firebase AI Logic to always return structured JSON output?

Define a strict JSON schema using the Schema object from firebase/ai and pass it as responseSchema in generationConfig for cloud params, or as responseConstraint inside promptOptions for on-device params. This guarantees the model's response is a parsable object matching the defined properties, eliminating the need for manual string parsing of AI responses.

_developers wiring structured AI outputs into their apps can find hands-on examples like this via daily.dev._

### How do I check if Gemini Nano is available in a user's browser before running an on-device AI task?

Access the chromeAdapter's languageModelProvider from the model instance and call its availability method with the onDeviceParams.createOptions, checking if the result equals "available". If it returns anything else, Gemini Nano isn't ready on that device, so the app should show a fallback notice and route the request to a cloud model like gemini-2.5-flash-lite instead.

_daily.dev helps developers track on-device AI availability checks like this Gemini Nano pattern._

## Similar posts on daily.dev

- [Experimental hybrid inference and new Gemini models for Android](https://daily.dev/posts/experimental-hybrid-inference-and-new-gemini-models-for-android-cc5bn1znk) · Android Developers Blog · 1 upvotes · 0 comments
- [Serverless AI for Android with Firebase AI Logic](https://daily.dev/posts/serverless-ai-for-android-with-firebase-ai-logic-33d7pefc4) · ProAndroidDev · 0 upvotes · 0 comments
- [Building “Personal Gemini Journal”: A Secure, AI-Powered Journaling Application with Google AI Studio & Cloud Run](https://daily.dev/posts/building-personal-gemini-journal-a-secure-ai-powered-journaling-application-with-google-ai-studi-odnqzcttm) · Medium · 0 upvotes · 0 comments
- [Google adds Nano Banana image generation to Gemini's Personal Intelligence feature](https://daily.dev/posts/google-adds-nano-banana-image-generation-to-gemini-s-personal-intelligence-feature-cubjtgcx5) · The Next Web · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#react](https://daily.dev/tags/react), [#local-ai](https://daily.dev/tags/local-ai)

[View this post on daily.dev](https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Smart photo organization through privacy-first, on-device AI","url":"https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus"},"datePublished":"2026-08-23T12:18:56.842Z","dateModified":"2026-08-23T12:27:47.337Z","description":"A walkthrough of building a privacy-first photo organization PWA using Firebase AI Logic SDK with hybrid inference: on-device Gemini Nano runs in-browser when...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/553b2891987c199c3d2140774587d8da?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/553b2891987c199c3d2140774587d8da?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"webdev,react,local-ai","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Smart photo organization through privacy-first, on-device AI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/smart-photo-organization-through-privacy-first-on-device-ai-56vztzsus#faq","mainEntity":[{"@type":"Question","name":"How do I set up hybrid AI inference with Firebase AI Logic so it uses Gemini Nano on-device but falls back to a cloud model?","acceptedAnswer":{"@type":"Answer","text":"Set the mode to InferenceMode.PREFER_ON_DEVICE when calling getGenerativeModel, and define both inCloudParams (e.g. specifying gemini-2.5-flash-lite with a responseSchema) and onDeviceParams (with promptOptions.responseConstraint and createOptions for expected inputs/outputs). The Firebase AI Logic SDK then automatically checks if Gemini Nano is available in the browser and falls back to the cloud model when it isn't. daily.dev surfaces practical Firebase AI Logic patterns for developers building hybrid on-device and cloud AI features."}},{"@type":"Question","name":"How can I force a model in Firebase AI Logic to always return structured JSON output?","acceptedAnswer":{"@type":"Answer","text":"Define a strict JSON schema using the Schema object from firebase/ai and pass it as responseSchema in generationConfig for cloud params, or as responseConstraint inside promptOptions for on-device params. This guarantees the model's response is a parsable object matching the defined properties, eliminating the need for manual string parsing of AI responses. developers wiring structured AI outputs into their apps can find hands-on examples like this via daily.dev."}},{"@type":"Question","name":"How do I check if Gemini Nano is available in a user's browser before running an on-device AI task?","acceptedAnswer":{"@type":"Answer","text":"Access the chromeAdapter's languageModelProvider from the model instance and call its availability method with the onDeviceParams.createOptions, checking if the result equals \"available\". If it returns anything else, Gemini Nano isn't ready on that device, so the app should show a fallback notice and route the request to a cloud model like gemini-2.5-flash-lite instead. daily.dev helps developers track on-device AI availability checks like this Gemini Nano pattern."}}]}
```

