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
GoogleAI plugin also accepts GEMINI_API_KEY. You can pass the key explicitly as GoogleAI(api_key='...'), but using an environment variable keeps credentials out of source control.Install dependencies
Install the Genkit core package and the Google AI plugin:Install the Genkit CLI to use the Developer UI:
The Genkit CLI is distributed via npm regardless of the language you use for your app. Node.js 18+ is required only for the CLI and Developer UI — your Python application does not depend on Node.
Explore with the Developer UI
The Genkit CLI wraps your app with tracing and launches a local Developer UI where you can run flows interactively and inspect execution traces.This starts your app, then opens the Developer UI at
http://localhost:4000. From there you can:- Run the
tell_jokeflow against any input without restarting your app. - Inspect traces to see the full prompt and response exchanged with Gemini.
- Compare models by switching between available Gemini variants in real time.
Add structured output (optional)
Pass a Pydantic
BaseModel as the output schema and Genkit will validate the model’s response for you: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.
Concepts: Tools
Let models call Python functions to fetch data, take actions, and more.
Guides: Structured output
Return validated Pydantic models from any generation call.
Guides: Streaming
Stream tokens as they arrive with
ai.generate_stream().Plugins: Google AI
Full reference for the
genkit-google-genai plugin including Vertex AI and embeddings.Plugins overview
Browse available plugins: Vertex AI, Ollama, Anthropic, Firebase, and more.
Developer tools
Deep dive into the Genkit CLI and Developer UI.
