AI in action: Adding AI-powered reviews in Firebase: Web Architecture & Implementation Guide Firebase shipped AI Logic, a client-side SDK that lets web and mobile apps call Gemini and Imagen models without exposing API keys, according to a Firebase blog post by Alexander Nohe and Jeff Huleatt. Requests are routed through a proxy that holds the credentials and are gated by Firebase App Check attestation, and the SDK can fall back to on-device models such as Chrome's Gemini Nano. CodingCat.dev's breakdown demonstrates the feature in a Friendly Eats app that suggests a star rating as a user types a review, with the suggestion overridable by the reviewer. Original: https://codingcat.dev/post/firebase-2025-10-adding-ai-powered-reviews https://codingcat.dev/post/firebase-2025-10-adding-ai-powered-reviews Calling frontier multimodal models directly from a web or mobile client is a security minefield if you expose raw API keys or hardcode brittle system prompts in your frontend bundle. Following the announcement of AI in action: Adding AI-powered reviews by Alexander Nohe, Jeff Huleatt on the Official Firebase Blog https://firebase.blog/posts/2025/10/adding-ai-powered-reviews/ 2025-10-01 , here is our hands-on CodingCat.dev breakdown of what actually shipped, how it works under the hood, and how we wire it into production TypeScript, Next.js, Astro, SvelteKit, React, and Angular applications. Sometimes, the best AI feature is a subtle one. In our Friendly Eats app, we wanted to automatically suggest a star rating as a user wrote their full review. This not only reduces the friction of submitting a review, but had the unexpected benefit of helping users understand how others might perceive their review. As a Google Developer Expert GDE for Firebase and Senior Solutions Architect at CodingCat.dev, I evaluate every Firebase update through one lens: does it reduce boilerplate while keeping our runtime security and cloud bills predictable? Firebase AI Logic lets you invoke Gemini and Imagen models from client and edge apps using the Firebase Web SDK while keeping your API credentials off the wire, enforcing Firebase App Check, and managing server-side prompt templates centrally. AJ Pro-Tip from Alex: Combine Firebase AI Logic with server prompt templates, Firebase Remote Config feature flags, and project spend caps so you can iterate on prompts or swap Gemini models instantly without redeploying your Next.js or Astro frontend. As the user types in the dialog, the star rating automatically updates based on the content of their review. Importantly, the suggested star rating can also be overridden, because we want the reviewer to have the final say Read on to see what decisions we made to implement this new feature. We chose to use a client side SDK, in this case Firebase AI Logic. The primary reason that we chose to use Firebase AI Logic is to protect our Gemini API key. Using a server side SDK will also protect the API keys, but considering that we are not pulling in massive amounts of data and are just running quick inference, we decided to settle on Firebase AI Logic. First, Firebase AI Logic lets us use an on-device model if one is available, like Chrome’s Gemini Nano. That can help limit a significant number of calls to our Gemini API key. Remote Gemini calls made with AI Logic go through a proxy before reaching the Gemini model endpoints. The proxy stores the API keys so that we don’t need to include our Gemini API key in the client-side code. We can then make requests to the proxy and the proxy validates your app and forwards the API keys to the appropriate endpoint either Vertex AI with a service account or Google Generative AI with an API key . Another feature that Firebase AI Logic provides which helps keep our endpoints secure from abuse is automatic integration with Firebase App Check to ensure that requests originating to our AI endpoints come from your app. This is done through an attestation provider like ReCaptcha Enterprise and its invisible attestation mechanism. It may add a few ms before the first request to Gemini in the app, but is otherwise seamless to the user. Picking a model is a tradeoff between cost, speed, and quality. Normally, I start using the largest model and work my way down to the smaller models to determine whether the trade offs from a larger model to a smaller model make sense. Since we are really just asking for a small output of a star rating between 1 and 5, it’s likely that the smaller models will provide the results that we are looking for without the cost and slower performance of a larger model. If the star rating is off, we can fall back on our functionality that lets the reviewer update the rating themselves. We narrowed down our choices to Gemini Nano https://developer.chrome.com/docs/ai/get-started from the Hybrid SDK https://firebase.google.com/docs/ai-logic/hybrid-on-device-inference?api=dev and Gemini 2.5 Flash Lite https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-lite as the fallback option. This allows us to default to the built in AI API for users on supported browsers while falling back to Gemini Flash Lite for our other users. This decision can help us keep costs down for providing this feature as there is no cost for using Gemini Nano from the Hybrid SDK and the cost of Gemini 2.5 Flash Lite is much lower than other models while providing an acceptable amount of fidelity. We made two important decisions to design the most reliable prompt we could. First, we used structured output https://firebase.google.com/docs/ai-logic/generate-structured-output?api=dev so we only receive a JSON value containing the star rating back from the model. This helps prevent overly verbose responses for why a star rating was given,constraining the outputs to something that we can parse in our client code. The second thing we did to increase the accuracy was give examples in our prompt to guide our model on what we would consider a high rating versus a low rating. This is a great way to tune responses to better fit the culture of your app’s userbase. Based on the supplied review, translate the review to a star rating that is equivalent: