Firebase Genkit – A framework for building and deploying AI-powered apps

Firebase Genkit
Firebase Genkit

Firebase Genkit

AI has transitioned from research labs to everyday use over the past year and a half. Advanced language models have enabled AI-powered app features, but developing and refining these features beyond a prototype poses significant challenges. 

Many struggle to implement these features at scale and evaluate their performance for continuous improvement. Ensuring safety and stability adds complexity. 

  • We’re introducing Firebase Genkit, now available in beta to address this. 
  • Genkit is an open-source framework for JavaScript/TypeScript developers (with Go support coming soon) to create Node.js backends and integrate AI-powered features into new or existing apps using large language models and related services. 
  • Genkit streamlines the integration of diverse data sources, models, cloud services, agents, and more, using a code-centric approach familiar to developers.

Key features – Firebase Genkit

Genkit is your comprehensive companion for AI development, guiding you from prototype to production and beyond. With a wide range of features, Genkit streamlines your journey and empowers you to build innovative AI-powered apps. 

Let’s dive into the top Genkit features

1. Many models, one interface

Genkit provides plugins that give you access to popular models out of the box and flexible model abstraction. 

  • Trying out a new model is as easy as changing a single argument
import { geminiPro } from '@genkit-ai/vertexai';
import { ollama } from 'genkitx-ollama';
import { generate } from '@genkit-ai/ai';

function flipACoin(a, b) {
return Math.random() > 0.5 ? a : b;

const result = await generate({
model: flipACoin(geminiPro, 'ollama/gemma'),
config: { temperature: 0.3, maxOutputTokens: 200 },
prompt: 'What makes you the best LLM out there?',


2. Structured output

With Genkit and Zod schema, you can transform unstructured data into robust, maintainable, and scalable software applications. Say goodbye to data inconsistencies and hello to seamless data integration and analysis!

import { generate } from "@genkit-ai/ai";
import { geminiPro } from "@genkit-ai/vertexai";
import { z } from "zod";

const CreatureSchema = z.object({
name: z.string().describe('the name of the creature'),
hitPoints: z.number().describe('hit points, between 5 and 100'),
attacks: z.array(z.object({
name: z.string(),
damage: z.number().describe('amount of damage, between 2 and 25'),
})).describe('3 attacks the creature can use')

const createCreature = defineFlow({
name: "createCreature",
inputSchema: z.string(),
outputSchema: CreatureSchema,
(habitat) => {
const result = await generate({
model: geminiPro,
prompt: `You are a brilliant RPG designer. Generate a creature that lives in ${habitat}.`,
output: {schema: CreatureSchema}
// strongly typed and ready to go
return result.output();

console.log(await createCreature("a developer conference"));

3. Multimodal, multimedia

Genkit provides a common format for content that supports mixtures of text, data, and arbitrary media. 

  • This lets you use Genkit for models that perform any generative task (such as image generation), not just LLMs.
import { imagen2, geminiProVision } from '@genkit-ai/vertexai';
import { generate } from '@genkit-ai/ai';

const imageResult = await generate({
model: imagen2,
prompt: 'Generate an image of a very specific historical time and place.',
const generatedImage =;

const descriptionResult = await generate({
model: geminiProVision,
prompt: [
text: 'What is the historical time and place represented in this picture?',
{ media: generatedImage },

4. Prompt management with Dotprompt

The model you use, the parameters you supply, and the format you request all impact the quality of your output. 

  • Genkit offers Dotprompt, a prompt file format that lets you put everything into a single file.
model: vertexai/gemini-1.0-pro
temperature: 0.9
location: {type: string}
style: {type: string}
name: {type: string}
required: [location]
location: a restaurant

You are the world's most welcoming AI assistant and are currently working at {{location}}.

Greet a guest{{#if name}} named {{name}}{{/if}}{{#if style}} in the style of {{style}}{{/if}}.

5. Run flows locally

The local Genkit Developer UI lets you interact with essential AI components like models and retrievers, as well as manually test your end-to-end flows

6. Built for production

Genkit is fully instrumented with OpenTelemetry and custom metadata for enterprise-grade production monitoring.

  • There are also official plugins for Google Cloud and Firebase that help you export data to Google Cloud’s operations suite and integrate with Firebase services like Cloud Functions for Firebase, Firebase Authentication, App Check, and Firestore.
Firebase Services
Firebase Services

7. Authorization & security handling

Genkit provides mechanisms for managing authorization policies and contexts.

import { defineFlow, runFlow } from '@genkit-ai/flow';

export const selfSummaryFlow = defineFlow(
name: 'selfSummaryFlow',
inputSchema: z.object({uid: z.string()}),
outputSchema: z.string(),
authPolicy: (auth, input) => {
if (!auth) {
throw new Error('Authorization required.');
if (input.uid !== auth.uid) {
throw new Error('You may only summarize your own profile data.');
async (input) => { ... });

Get started

To get started with Firebase Genkit, install the Genkit CLI and run genkit init in a Node.js project. 

Node.js 20 or later.

npm i -g genkit
  • Create a new Node project:
mkdir genkit-intro && cd genkit-intro
npm init -y
  • Initialize a Genkit project:
genkit init
  • Select Node.js as the deployment platform option (templates for Firebase Cloud Functions and Google Cloud Run are also available).
  • Download and start the Genkit Developer UI:
genkit start
Firebase GenKit
Firebase GenKit

Valuable comments