Prerequisites
- Python 3.10 or later
- pip or uv package manager
- A Google AI API key (get one at Google AI Studio)
Step 1: Install Genkit
Install Genkit with the Google AI plugin:Step 2: Install Genkit CLI
The CLI is the same across all languages:Step 3: Set Your API Key
Set your Google AI API key as an environment variable:Step 4: Create Your First Application
Create a file namedapp.py:
app.py
Genkit for Python uses async/await. You’ll need to run this in an async context.
Step 5: Run Your Application
Since Genkit uses async functions, you need to run it properly:app.py
Access the Developer UI
When running withgenkit start, open http://localhost:4000 to access the Developer UI.
Create a Flow
Flows are the primary abstraction in Genkit for encapsulating AI logic:Generate Structured Output
Genkit can generate type-safe structured data using Pydantic models:Define Tools
Tools allow AI models to call your Python functions:Create an HTTP Server
Deploy your flows as HTTP endpoints using the built-in flow server:Use with Flask
You can also integrate Genkit with Flask:Try Other Model Providers
Genkit supports multiple AI providers:Development with uv
For faster dependency management, useuv:
Learn More
Python API Reference
Explore the complete Python API
Structured Output
Generate type-safe responses with Pydantic
Flask Integration
Deploy flows with Flask
Deployment
Deploy your Python applications