◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
Articles/Advanced
⬡ Advanced/2026-03-25Advanced

Building Serverless AI Apps with Firebase Genkit and Gemini — An Implementation Notebook

A hands-on implementation notebook for building serverless AI apps with Firebase Genkit and Gemini. Flows, agents, and RAG on the current Genkit 1.x API, plus per-flow usage logging that turns spend into an itemized bill, the gaps between the Dev UI and production, and cold-start tuning.

Firebase GenkitGemini92ServerlessAI9Development

✦ Premium Article

Shipping one Flow, and why the framework's thinness matters

When I first picked up Firebase Genkit, I was wary. Running Dolice Labs as an indie developer, every new abstraction layer is something to learn, and a tool that doesn't earn its keep becomes a liability.

That wariness lifted when I ran a tiny Flow — one that just returns a greeting — in the local Dev UI, and then deployed the exact same code to Cloud Functions. Input and output schemas, local testing, tracing, deployment: all of it sits inside one consistent way of writing. Because the framework is thin, you get to focus on the Gemini call itself.

This is an implementation notebook that walks from that first Flow all the way to RAG and agents, using code I actually wrote and verified. It isn't a line-by-line translation of the docs; it centers on the places an indie developer tends to get stuck. Note that this is a fast-moving area — the examples here assume the 1.x genkit() constructor and zod schemas.

Install and initialize — consolidate in one place

Install Genkit and the Google AI plugin. TypeScript is the natural choice.

npm install genkit @genkit-ai/googleai
npm install -D typescript tsx @types/node

Consolidate initialization into a single file and import ai from it everywhere else, so swapping models is a one-line change.

// src/genkit.ts
import { genkit } from "genkit";
import { googleAI } from "@genkit-ai/googleai";
 
// Swap the model ID for whichever you want (a current Flash / Pro model)
export const ai = genkit({
  plugins: [googleAI({ apiKey: process.env.GOOGLE_API_KEY })],
  model: googleAI.model("gemini-2.5-flash"),
});

Never hardcode apiKey; always pass it from the environment. Use .env locally, and the Secret Manager path shown below in production.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Copy-runnable Flow, Tool, and RAG code written against the current Genkit 1.x API (the genkit constructor and zod schemas)
✦A usage-logging wrapper and aggregation script that report cost per 1,000 calls, plus how to cut the input-token tail
✦How to isolate the four things that pass in the Dev UI but break in production, and when a minimum instance is worth paying for
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Advanced2026-10-17
After exporting a Gemini answer to Docs, check who can open it before you hit Share
Google's help page for "Export to Docs" covers creating the document, not its sharing state. Here are the three places to look right after exporting, what happens when you move the file into a shared folder, and an Apps Script audit for when exports pile up.
⬡ Advanced2026-09-17
The color label Gemini returned for the same wallpaper changed — and the model was not the reason
I counted color-label agreement across five ways of exporting the same wallpaper. Stripping the ICC profile was the worst of them. Here is how I pin the color space down before asking, and how I check the answers against a number I compute myself.
⬡ Advanced2026-10-14
Fine on Desktop, Blank on Safari: Four Things to Gather Before You Ask an AI to Diagnose It
After a shuffle, my lazy-loaded images never loaded again, but only in Safari on iPhone. Here is what to collect by hand before asking Gemini or any other model to diagnose a bug that does not reproduce on desktop, plus a request template you can paste.