1.1 The Pantry (Introduction & Setup)
Welcome to The Pantry! This is where we prepare our development environment for the Master Genkit course. My name is Maina Wycliffe, and I’ll be your instructor throughout this culinary journey into the world of Genkit and AI development with TypeScript.
Please note, this course assumes you have a basic knowledge of TypeScript and Node.js. If you’re new to these technologies, consider checking out introductory resources before proceeding. You should be comfortable navigating the command line and using a code editor.
What is Genkit?
Section titled “What is Genkit?”Genkit is a powerful TypeScript library that simplifies the process of building AI-powered applications. It provides a clean and intuitive API for interacting with various AI models, making it easier to integrate AI capabilities into your projects. Whether you’re building chatbots, content generators, or any other AI-driven application, Genkit has got you covered.
Every AI model provider has its own unique API and way of doing things. Genkit standardizes these differences, allowing you to switch between providers or use different providers with minimal effort. This means you can focus on building your application without worrying about the intricacies of each AI model’s API. You don’t have to worry about what happens when Google releases Gemini 2 or OpenAI releases GPT-5. Genkit will handle all the changes for you.
Ingredients
Section titled “Ingredients”- Node.js 22+ (v24+ recommended)
- TypeScript 5.5+
- A code editor (VS Code - author’s choice)
- Git
You can download the above ingredients from their official websites.
Setting Up Your Kitchen
Section titled “Setting Up Your Kitchen”-
Install Node.js: Download and install Node.js from the official website. Ensure you have version 22 or higher. I recommend using the latest LTS version (v24+ as of the time of writing this).
I would recommend using a version manager like
nvmto manage multiple Node.js versions, making it easier to switch between them, for different projects.You can verify your installation by running:
Terminal window node -v // should be v22+npm -v // should be v9+ -
Install Typescript globally if you haven’t already:
Terminal window npm install -g typescriptVerify the installation:
Terminal window tsc -v // should be 5.5+ -
Download a code editor like Visual Studio Code or WebStorm.
-
Download and install Git from the official website. This will allow you to clone repositories easily.
You can confirm git is installed correctly by running the following command in the terminal:
Terminal window git --version -
Set Up Your Project:
The easiest way to get started is by cloning the Genkit Starter Kit repository. Open your terminal and run:
Terminal window git clone https://github.com/mainawycliffe/genkit-starter-kit.gitcd genkit-typescript-templateYou can also clone to a specific folder by running:
Terminal window git clone https://github.com/mainawycliffe/genkit-starter-kit.git <your-project-name>cd <your-project-name> -
Install Dependencies:
Inside your project directory, run:
Terminal window npm installThis will install all the necessary packages listed in the
package.jsonfile. -
Configure Environment Variables:
First, we need to fetch our Gemini API key. We can get one for free from AI Studio.
Once you have your API key, create a
.envfile in the root of your project and add the following line:GEMINI_API_KEY=your_gemini_api_key_hereReplace
your_gemini_api_key_herewith the actual API key you obtained from AI Studio.For other AI Model providers, such as OpenAI, Anthropic, etc., we will see later on how to set them up to work with Genkit. Every recipe in this course should work with any AI model provider of your choice.
if you open
src/index.ts, you will see the following content:import { googleAI } from '@genkit-ai/google-genai';import { genkit } from 'genkit';const ai = genkit({plugins: [googleAI()],model: googleAI.model('gemini-2.0-flash'),});async function main() {const { text } = await ai.generate('Tell me a joke?');console.log('...............');console.log('Gemini Response');console.log(text);}main();The above is a very simple example of what we can do with Genkit. We are using Gemini, and then prompting gemini-2.0 flash to generate a joke for us.
Run Your Project:
You can now run the starter project to ensure everything is set up correctly. In your terminal, run:
Terminal window npm run run:devIn your terminal, you will see a joke. Feel free to play with the prompt and see what happens. You can also switch to another model, such as GPT - make sure you have the correct API Keys for open AI (
OPENAI_API_KEY) - as shown below:import { openAI } from '@genkit-ai/compat-oai/openai';import { genkit } from 'genkit';const ai = genkit({// 1. add openAI Pluginplugins: [openAI()],// specify default model for openAImodel: openAI.model('gpt-4'),});// No changes hereasync function main() {const { text } = await ai.generate('Tell me a joke?');console.log('...............');console.log('Gemini Response');console.log(text);}main();As you can see, we didn’t touch the main function, we just switched out our model and switching from the Gemini Plugin to the Open AI Plugin, we can do this for each model, as you will see in the next steps.
Congratulations! Your kitchen is now set up and ready for cooking with Genkit. In the next section, we’ll explore the essential tools and techniques you’ll need to master Genkit and create amazing AI-powered applications with TypeScript. Let’s get cooking!