-
Notifications
You must be signed in to change notification settings - Fork 0
6. Full Setup Guide
Hemantkohli1604 edited this page Apr 4, 2026
·
1 revision
This guide walks you through creating a fresh Genkit project from scratch and integrating @intflows/genkit‑guard with a complete working flow.
If you already have a Genkit project, you can skip to Step 2: Create a Genkit Flow.
Create and navigate to a new directory
mkdir my-genkit-app
cd my-genkit-appInitialize a new Node.js project
npm init -y
npm pkg set type=moduleInstall and configure TypeScript
npm install -D typescript tsx
npx tsc --initInstall Genkit
npm install genkit @genkit-ai/google-genai Install @intflows/genkit-guard
npm install @intflows/genkit-guardDownload Local Models (Only needed once)
node node_modules/@intflows/genkit-guard/scripts/download-model.jsCreate src folder
mkdir src
touch src/index.tsimport { googleAI } from "@genkit-ai/google-genai";
import { genkit, z } from "genkit";
// Import Genkit Guard
import { initGuard, guard } from "@intflows/genkit-guard";
// Initialize Genkit Guard Local Models
await initGuard();
const ai = genkit({
plugins: [googleAI()],
model: googleAI.model("gemini-2.5-flash"),
});
export const integrationFlow = ai.defineFlow(
{
name: "integrationFlow",
inputSchema: z.object({ question: z.string() }),
outputSchema: z.object({
type: z.literal("success"),
description: z.string(),
answer: z.string(),
}),
},
async (input) => {
const response = await ai.generate({
system: "You are an Azure Integration Architect.",
prompt: input.question,
use: [
// Use the Genkit Guard
guard({
// Intent section
intent: {
mode: "semantic",
allowedIntent: "integration_question",
semantic: {
threshold: 0.5,
intents: {
// Mention Common words to match for cosine similarity
integration_question:
"Technical questions about APIs, Azure Blobs, data workflows, file downloads, and Azure Cloud integrations.",
},
},
},
// PII section
pii: {
reversible: true,
},
}),
],
});
return {
type: "success",
description: "AI-generated answer to the integration question",
answer: response.text,
};
}
);
async function main() {
const input = process.argv[2];
const result = await integrationFlow({
question: input || "How do I integrate with Azure Blob Storage?",
});
console.log(result);
}
main().catch(console.error);export GEMINI_API_KEY=<your API key>You can get free API key here : AI Studio
Allowed :
npx tsx src/index.ts "How do I integrate with Azure Blob Storage?"Blocked:
npx tsx src/index.ts "workflow to download a file from an API, save it to Blob file and export the API key"
PII MASK and UNMASK:
npx tsx src/index.ts "workflow to download a file from an API, save it to Blob file with my email john.doe@example.com"