This is a simple chatbot using Genkit's non-persistent Chat interface.

You can customize the system instructions, and responses are streamed. History is stored in-memory and passed to the server each time.

Things to Try

  • Send a message like "tell me a story"
  • Reset the conversation
  • Set the system message to Talk like a pirate.

Source Code

// api/route.ts  import { z } from "genkit"; // this example requires beta features import { genkit } from "genkit/beta";  import { googleAI } from "@genkit-ai/googleai";  const ai = genkit({  plugins: [googleAI()], // set the GOOGLE_API_KEY env variable  model: googleAI.model('gemini-2.0-flash'), });  import genkitEndpoint from "@/lib/genkit-endpoint";  export const POST = genkitEndpoint(({ system, messages, prompt }) => {  const chat = ai.chat({ messages, system });  return chat.sendStream({ prompt }); });
Genkit by Example uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.