Skip to main content
This guide will help you create your first AI-powered application using Genkit for JavaScript/TypeScript. You’ll learn how to initialize Genkit, make your first generation request, and run it with the Developer UI.

Prerequisites

  • Node.js 18 or later
  • npm, yarn, or pnpm
  • A Google AI API key (get one at Google AI Studio)

Step 1: Install Dependencies

Create a new project and install Genkit:

Step 2: Set Your API Key

Set your Google AI API key as an environment variable:
You can also create a .env file in your project root:

Step 3: Create Your First Application

Create a file named index.ts (or index.js for JavaScript):
index.ts
If you’re using JavaScript instead of TypeScript, you’ll need to use ES modules. Add "type": "module" to your package.json.

Step 4: Run Your Application

Run your application with the Genkit CLI to get automatic tracing and access to the Developer UI:
For JavaScript:
You should see output similar to:

Step 5: Explore the Developer UI

Open http://localhost:4000 in your browser to access the Genkit Developer UI. Here you can:
  • View execution traces of your AI requests
  • Test different prompts interactively
  • Compare outputs from different models
  • Debug multi-step flows

What’s Next?

Add Streaming

Stream responses for better user experience:

Generate Structured Output

Get type-safe JSON responses:

Create a Flow

Flows are functions that encapsulate AI logic with automatic tracing:

Add Tool Calling

Give your AI the ability to call functions:

Try Other Model Providers

Genkit supports multiple AI providers:

Learn More

Text Generation

Learn about different generation options

Structured Output

Generate type-safe JSON responses

Tool Calling

Give AI models access to functions

Developer Tools

Explore the Developer UI features