Skip to main content
This guide walks you through installing Genkit, writing your first AI-powered function, and exploring it with the local Developer UI.
1

Get a Google AI API key

Genkit’s Google AI plugin uses the Gemini API. Get a free API key from Google AI Studio.
Set the key as an environment variable before running any Genkit code:
The plugin also accepts GEMINI_API_KEY and GOOGLE_API_KEY. You can alternatively pass the key directly as googleAI({ apiKey: '...' }), but using an environment variable is recommended so credentials are never committed to source control.
2

Install dependencies

Create a new Node.js project (or open an existing one), then install Genkit and the Google AI plugin:
Install the Genkit CLI globally so you can use the Developer UI:
3

Write your first Genkit app

Create src/index.ts with the following content:
Run it with tsx (or compile with tsc first):
4

Explore with the Developer UI

The Genkit CLI wraps your app with tracing and launches a local Developer UI where you can run flows, inspect execution traces, and compare model outputs interactively.
The CLI starts your app, then opens the Developer UI at http://localhost:4000. In the UI you can:
  • Run the tellJoke flow against any input without touching your code.
  • Inspect traces to see exactly what was sent to and received from the model.
  • Tweak prompts and compare outputs across different Gemini model variants.
Set GENKIT_ENV=dev in your environment to keep the reflection server running even outside the genkit start command, which is useful during active development.
5

Add structured output (optional)

Genkit can validate model responses against a Zod schema and return typed objects:

Next steps

Concepts: Flows

Learn how flows add observability, retries, and HTTP exposure to any AI function.

Concepts: Models

Understand model references, config options, multimodal inputs, and streaming.

Guides: Structured output

Return validated, type-safe JSON from any model call using Zod schemas.

Guides: Streaming

Stream tokens to the client as they are generated for a faster perceived response.

Guides: Agents

Build multi-step agentic workflows with tool calling and looping.

Plugins: Google AI

Full reference for the @genkit-ai/google-genai plugin including Vertex AI, Imagen, and embeddings.

Plugins overview

Browse all available plugins: Vertex AI, Ollama, Firebase, and community providers.

Developer tools

Deep dive into the Genkit CLI and Developer UI.