
Product
Introducing Immutable Scans
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.
Genkit is a framework for building AI-powered applications. It provides open source libraries for Node.js and Go, along with tools to help you debug and iterate quickly.
Install the following Genkit dependencies to use Genkit in your project:
genkit provides Genkit core capabilities.@genkit-ai/googleai provides access to the Google AI Gemini models. Check out other plugins: https://www.npmjs.com/search?q=keywords:genkit-pluginnpm install genkit @genkit-ai/googleai
Get started with Genkit in just a few lines of simple code.
// import the Genkit and Google AI plugin libraries
import { genkit } from 'genkit';
import { googleAI } from '@genkit-ai/google-genai';
const ai = genkit({ plugins: [googleAI()] });
const { text } = await ai.generate({
model: googleAI.model('gemini-2.5-flash'),
prompt: 'Why is Genkit awesome?'
});
Genkit also provides middleware to add common functionality to your AI requests. For example, you can use the retry middleware to automatically retry failed requests:
import { retry } from 'genkit/model/middleware';
const { text } = await ai.generate({
model: googleAI.model('gemini-2.5-flash'),
prompt: 'Why is Genkit awesome?',
use: [
retry({
maxRetries: 3,
initialDelayMs: 1000,
backoffFactor: 2,
}),
],
});
Genkit also lets you build strongly typed, accessible from the client, fully observable AI flows:
import { googleAI } from '@genkit-ai/google-genai';
import { genkit, z } from 'genkit';
// Initialize Genkit with the Google AI plugin
const ai = genkit({
plugins: [googleAI()],
model: googleAI.model('gemini-2.5-flash', {
temperature: 0.8
}),
});
// Define input schema
const RecipeInputSchema = z.object({
ingredient: z.string().describe('Main ingredient or cuisine type'),
dietaryRestrictions: z.string().optional().describe('Any dietary restrictions'),
});
// Define output schema
const RecipeSchema = z.object({
title: z.string(),
description: z.string(),
prepTime: z.string(),
cookTime: z.string(),
servings: z.number(),
ingredients: z.array(z.string()),
instructions: z.array(z.string()),
tips: z.array(z.string()).optional(),
});
// Define a recipe generator flow
export const recipeGeneratorFlow = ai.defineFlow(
{
name: 'recipeGeneratorFlow',
inputSchema: RecipeInputSchema,
outputSchema: RecipeSchema,
},
async (input, { sendChunk }) => {
// Create a prompt based on the input
const prompt = `Create a recipe with the following requirements:
Main ingredient: ${input.ingredient}
Dietary restrictions: ${input.dietaryRestrictions || 'none'}`;
// Generate structured recipe data using the same schema
const { output } = await ai.generate({
prompt,
output: { schema: RecipeSchema },
onChunk: sendChunk // stream output
});
if (!output) throw new Error('Failed to generate recipe');
return output;
}
);
// Run the flow locally
async function main() {
const recipe = await recipeGeneratorFlow({
ingredient: 'avocado',
dietaryRestrictions: 'vegetarian'
});
console.log(recipe);
}
main().catch(console.error);
You can easily serve flows as an API:
import { startFlowServer } from '@genkit-ai/express'; // npm i @genkit-ai/express
startFlowServer({
flows: [recipeGeneratorFlow],
});
And access the flow from the client:
import { runFlow } from 'genkit/beta/client';
const { stream } = streamFlow({
url: 'http://localhost:3500/recipeGeneratorFlow',
input: {
ingredient: 'avocado',
dietaryRestrictions: 'vegetarian'
},
});
for await (const chunk of stream) {
console.log(chunk);
}
For more details see: https://genkit.dev/docs/deploy-node
But you can also deploy to Firebase or Cloud Run, etc.
Now that you’re set up to make model requests with Genkit, learn how to use more Genkit capabilities to build your AI-powered apps and workflows. To get started with additional Genkit capabilities, see the following guides:
Learn more at https://genkit.dev
License: Apache 2.0
FAQs
Genkit AI framework
The npm package genkit receives a total of 161,085 weekly downloads. As such, genkit popularity was classified as popular.
We found that genkit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.